|
5 | 5 | @component('components.code')
|
6 | 6 | auth: {
|
7 | 7 | routes: {
|
8 |
| - login : 'login', // a route to login a user |
9 |
| - logout : 'logout', // a route to logout a user |
10 |
| - auth : 'auth' // a route to check for auth |
| 8 | + login : 'login', // a route to login a user |
| 9 | + logout : 'logout', // a route to logout a user |
| 10 | + auth : 'auth', // a route to check for auth |
| 11 | + register : 'register' // a route to check for auth |
11 | 12 | },
|
12 | 13 |
|
13 | 14 | methods: {
|
14 |
| - login : 'post', // the method to use for login |
15 |
| - logout : 'post', // the method to use for logout |
16 |
| - auth : 'get' // the method to use for auth |
| 15 | + login : 'post', // the method to use for login |
| 16 | + logout : 'post', // the method to use for logout |
| 17 | + auth : 'get', // the method to use for auth |
| 18 | + register : 'post' // the method to use for auth |
17 | 19 | },
|
18 | 20 |
|
19 | 21 | modelPrefix: false // whether or not to prefix the model name in the requests
|
|
30 | 32 | User.login({ username: 'user', password: 'password' }).then(...) // config.auth.methods.login => /api/login
|
31 | 33 | User.logout().then(...) // config.auth.methods.logout => /api/logoout
|
32 | 34 | User.check().then(...) // config.auth.methods.auth => /api/auth
|
| 35 | +User.register({ name: 'rapid', email: 'user@email.com', password: 'password' }).then(...) // config.auth.methods.register => /api/register |
33 | 36 |
|
34 | 37 | // all regular methods are still available too
|
35 | 38 | User.find(1).then(...) // GET => /api/user/1
|
|
42 | 45 | modelName: 'User',
|
43 | 46 | auth: {
|
44 | 47 | routes: {
|
45 |
| - auth: 'authenticate' |
| 48 | + auth: 'authenticate', |
| 49 | + register: 'sign-up' |
46 | 50 | },
|
47 | 51 | modelPrefix: true
|
48 | 52 | }
|
|
51 | 55 | User.login({ username: 'user', password: 'password' }).then(...) // config.auth.methods.login => /api/user/login
|
52 | 56 | User.logout().then(...) // config.auth.methods.logout => /api/user/logoout
|
53 | 57 | User.check().then(...) // config.auth.methods.auth => /api/user/authenticate
|
| 58 | +User.register({ name: 'rapid', email: 'user@email.com', password: 'password' }).then(...) // config.auth.methods.register => /api/user/sign-up |
54 | 59 | @endcomponent
|
0 commit comments