Add backend support for login status checks
This commit is contained in:
parent
54dad8013b
commit
8cd1409eb6
@ -44,8 +44,7 @@ export class Login extends Controller {
|
||||
|
||||
await this.security.authenticate(user)
|
||||
|
||||
return redirect('/')
|
||||
|
||||
return api.one(user)
|
||||
}
|
||||
|
||||
public async register() {
|
||||
@ -70,6 +69,10 @@ export class Login extends Controller {
|
||||
// then login
|
||||
await this.security.authenticate(newUser)
|
||||
|
||||
return redirect('/')
|
||||
return api.one(newUser)
|
||||
}
|
||||
|
||||
public async logout() {
|
||||
await this.security.flush()
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Route, SessionAuthMiddleware} from '@extollo/lib'
|
||||
import {Route, AuthRequiredMiddleware, GuestRequiredMiddleware, SessionAuthMiddleware} from '@extollo/lib'
|
||||
import {Home} from '../controllers/main/Home.controller'
|
||||
import {Login} from '../controllers/api/Login.controller'
|
||||
|
||||
@ -14,17 +14,24 @@ Route.group('/', () => {
|
||||
|
||||
Route.group('/login', () => {
|
||||
Route.post('/')
|
||||
.pre(GuestRequiredMiddleware)
|
||||
.calls<Login>(Login, login => login.login)
|
||||
|
||||
Route.get('/status')
|
||||
.calls<Login>(Login, login => login.status)
|
||||
|
||||
Route.get('/user')
|
||||
.pre(AuthRequiredMiddleware)
|
||||
.calls<Login>(Login, login => login.user)
|
||||
|
||||
})
|
||||
|
||||
Route.post('/register')
|
||||
.pre(GuestRequiredMiddleware)
|
||||
.calls<Login>(Login, login => login.register)
|
||||
|
||||
Route.post('/logout')
|
||||
.pre(AuthRequiredMiddleware)
|
||||
.calls<Login>(Login, login => login.logout)
|
||||
})
|
||||
}).pre(SessionAuthMiddleware)
|
||||
|
Loading…
Reference in New Issue
Block a user