backend/app/controllers/Home.controller.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-02-09 05:29:10 +00:00
const Controller = require('libflitter/controller/Controller');
2020-02-08 01:50:10 +00:00
/*
* Home Controller
* -------------------------------------------------------------
* Controller for the main homepage of this Flitter app. Methods here
* are used as handlers for routes specified in the route files.
*/
class Home extends Controller {
static get services() {
return [...super.services, 'configs'];
}
2020-02-08 01:50:10 +00:00
/*
* Serve the main welcome page.
2020-02-08 01:50:10 +00:00
*/
welcome(req, res) {
return res.redirect('/i')
}
async get_login(req, res) {
const AppName = this.configs.get('app.name');
return res.page('login', { AppName });
}
toApp(req, res) {
return res.redirect('/i');
}
async get_stat(req, res, next) {
return res.api({
noded: true,
app_name: this.configs.get('app.name'),
system_base: this.configs.get('app.url'),
authenticated_user: !!req.user,
public_user: !!req?.user?.is_public_user(),
})
}
2020-02-08 01:50:10 +00:00
}
2020-02-09 05:29:10 +00:00
module.exports = Home;