aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/app/Controllers/Http/DashboardController.js
blob: 69af16227ee6cfa6dcd9e058134809aa3905ae0e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class DashboardController {
  async data({
    auth,
    view,
  }) {
    const general = auth.user;
    const services = (await auth.user.services().fetch()).toJSON();
    const workspaces = (await auth.user.workspaces().fetch()).toJSON();

    return view.render('dashboard.data', {
      username: general.username,
      mail: general.email,
      created: general.created_at,
      updated: general.updated_at,
      services,
      workspaces,
    });
  }

  logout({
    auth,
    response,
  }) {
    auth.authenticator('session').logout();
    return response.redirect('/user/login');
  }

  delete({
    auth,
    response,
  }) {
    auth.user.delete();
    auth.authenticator('session').logout();
    return response.redirect('/user/login');
  }
}

module.exports = DashboardController;