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)
|
await this.security.authenticate(user)
|
||||||
|
|
||||||
return redirect('/')
|
return api.one(user)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async register() {
|
public async register() {
|
||||||
@ -70,6 +69,10 @@ export class Login extends Controller {
|
|||||||
// then login
|
// then login
|
||||||
await this.security.authenticate(newUser)
|
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 {Home} from '../controllers/main/Home.controller'
|
||||||
import {Login} from '../controllers/api/Login.controller'
|
import {Login} from '../controllers/api/Login.controller'
|
||||||
|
|
||||||
@ -14,17 +14,24 @@ Route.group('/', () => {
|
|||||||
|
|
||||||
Route.group('/login', () => {
|
Route.group('/login', () => {
|
||||||
Route.post('/')
|
Route.post('/')
|
||||||
|
.pre(GuestRequiredMiddleware)
|
||||||
.calls<Login>(Login, login => login.login)
|
.calls<Login>(Login, login => login.login)
|
||||||
|
|
||||||
Route.get('/status')
|
Route.get('/status')
|
||||||
.calls<Login>(Login, login => login.status)
|
.calls<Login>(Login, login => login.status)
|
||||||
|
|
||||||
Route.get('/user')
|
Route.get('/user')
|
||||||
|
.pre(AuthRequiredMiddleware)
|
||||||
.calls<Login>(Login, login => login.user)
|
.calls<Login>(Login, login => login.user)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Route.post('/register')
|
Route.post('/register')
|
||||||
|
.pre(GuestRequiredMiddleware)
|
||||||
.calls<Login>(Login, login => login.register)
|
.calls<Login>(Login, login => login.register)
|
||||||
|
|
||||||
|
Route.post('/logout')
|
||||||
|
.pre(AuthRequiredMiddleware)
|
||||||
|
.calls<Login>(Login, login => login.logout)
|
||||||
})
|
})
|
||||||
}).pre(SessionAuthMiddleware)
|
}).pre(SessionAuthMiddleware)
|
||||||
|
Loading…
Reference in New Issue
Block a user