Add support for fetching session data; add /start url
(Noded/frontend#15)
This commit is contained in:
26
app/controllers/api/v1/Session.controller.js
Normal file
26
app/controllers/api/v1/Session.controller.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const { Controller } = require('libflitter')
|
||||
|
||||
class SessionController extends Controller {
|
||||
static get services() {
|
||||
return [...super.services, 'configs']
|
||||
}
|
||||
|
||||
async get_session(req, res, next) {
|
||||
return res.api(await this.session_data(req.user))
|
||||
}
|
||||
|
||||
async session_data(user) {
|
||||
return {
|
||||
user: {
|
||||
id: user.id,
|
||||
username: user.uid,
|
||||
},
|
||||
app: {
|
||||
name: this.configs.get('app.name'),
|
||||
url: this.configs.get('app.url'),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = SessionController
|
||||
Reference in New Issue
Block a user