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_to
relationship with the Gender table.The Users table has a unique constraint on both
username
andemail
to 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_many
Permissions. -
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
admin
which will be assigned to the first User to create an account. theadmin
User 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_many
Users.
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
username
andpassword
and returns a signed UserToken. - GET /users/:user_id?permission=":permission"
When provided with a
permission
in 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.sh
to create the requiredpostgresql
users - 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