{ "protocol" : "UserAuthentication", "namespace" : "Switchboard", "types" : [ { "type" : "record", "name" : "UserAuthenticationUser", "doc" : "The main User class", "fields" : [ { "name" : "id", "type" : "int", "doc" : "The primary key" }, { "name" : "name", "type" : "string", "doc" : "Their name" }, { "name" : "email_address", "type" : "string", "doc" : "The email address of the user" }, { "name" : "permissions", "type" : { "type" : "array", "items" : "string" }, "doc" : "An array of the names of all permissions the user has" }, { "name" : "lawyer_id", "type" : [ "null", "int" ], "doc" : "The id of the lawyer this user has claimed, if any" } ] }, { "type" : "record", "name" : "UserAuthentication", "fields" : [ { "name" : "user", "type" : "UserAuthenticationUser", "doc" : "The authorized user" }, { "name" : "access_token", "type" : "string", "doc" : "An OAuth2 access token the client can use on this user's behalf" } ] }, { "type" : "record", "name" : "UserRegistrationParams", "doc" : "When registering a user, provide these options", "fields" : [ { "name" : "email_address", "type" : "string", "doc" : "User's email address" }, { "name" : "password", "type" : "string", "doc" : "User's new password" }, { "name" : "name", "type" : [ "string", "null" ], "doc" : "User's display name name" } ] }, { "type" : "enum", "name" : "SocialNetwork", "doc" : "All the allowed different social networks that we can auth via", "symbols" : [ "FACEBOOK", "GOOGLE", "TWITTER", "LINKEDIN" ] } ], "messages" : { "register" : { "doc" : "POST: Register a user by email_address and password", "request" : [ { "name" : "user", "type" : "UserRegistrationParams" } ], "response" : { "type" : "array", "items" : "UserAuthentication" } }, "authenticate" : { "doc" : "POST: Authenticate a user via email_address and password", "request" : [ { "name" : "email_address", "type" : "string" }, { "name" : "password", "type" : "string" } ], "response" : { "type" : "array", "items" : "UserAuthentication" } }, "find_or_create_via_social" : { "doc" : "POST: Login or register via a social network", "request" : [ { "name" : "social_network", "type" : "SocialNetwork" }, { "name" : "access_token", "type" : "string" }, { "name" : "secret", "type" : [ "null", "string" ] } ], "response" : { "type" : "array", "items" : "UserAuthentication" } } } }