The UserService handles storage and management of Users. The required tables are as follows:
-
Users The Users table contains important information about the User such as
email,username, andpassword. The Users table also has abelongs_torelationship with the Gender table.The Users table has a unique constraint on both
usernameandemailto ensure that we don't have name conflicts and that each user can only make one account. This can be circumvented by creating additional emails to register more accounts, but who really cares tbh.Users
has_manyPermissions. -
Permissions Permissions should be a list of named permissions that other services will recognize and be able to adapt to.
Initially, the Permissions table will be pre-loaded with
adminwhich will be assigned to the first User to create an account. theadminUser will be able to alter the permissions of other Users.Columns:
name, the name of the permissiondescription, a detailed description of the permission so developers of other services will be able to use these permissions effectively.Permissions
has_manyUsers.
The UserService is also responsible for signing User Tokens that other services can relay to the UserService in order to ensure a User is who they say they are.
Endpoints:
- POST /users/create The URL used to create Users.
- GET /users/:user_id The URL to get information about a specific User.
- POST /users/authenticate
The URL that verifies a User is real with a
usernameandpasswordand returns a signed UserToken. - GET /users/:user_id?permission=":permission"
When provided with a
permissionin the payload, it provides whether a user has this permission. - GET /users/:user_id/permissions Lists all permissions owned by the user
- GET /permissions A list of all available permissions and their descriptions.
- POST /permissions/create The URL used to create permissions
To start your Phoenix app:
- Run
setup.shto create the requiredpostgresqlusers - Install dependencies with
mix deps.get - Create and migrate your database with
mix ecto.create && mix ecto.migrate - Start Phoenix endpoint with
mix phoenix.server
Now you can visit localhost:4000 from your browser.
Ready to run in production? Please check our deployment guides.
- Official website: http://www.phoenixframework.org/
- Guides: http://phoenixframework.org/docs/overview
- Docs: https://hexdocs.pm/phoenix
- Mailing list: http://groups.google.com/group/phoenix-talk
- Source: https://github.com/phoenixframework/phoenix