From c34801327710c01a702b4178104e15ca11e6c925 Mon Sep 17 00:00:00 2001
From: Eugen Ciur <eugen@papermerge.com>
Date: Fri, 22 Oct 2021 20:46:32 +0200
Subject: [PATCH] Introduce Ember Simple Authentication

---
 app/app.js                                    |  1 +
 app/authenticators/auth-token.js              | 35 +++++++++++
 app/authenticators/oauth2.js                  |  9 ---
 app/base/routing.js                           | 12 ++++
 app/components/nav/sidebar.hbs                | 15 ++---
 app/components/role/edit.hbs                  |  2 +-
 app/components/role/table_row.hbs             |  2 +-
 app/components/user/table_row.hbs             |  4 +-
 app/controllers/login.js                      | 10 +++-
 app/router.js                                 | 60 ++++++++++---------
 .../{ => authenticated}/automates/index.js    |  5 +-
 app/routes/{ => authenticated}/document.js    |  0
 app/routes/{ => authenticated}/groups.js      |  5 +-
 app/routes/{ => authenticated}/index.js       |  1 +
 app/routes/{ => authenticated}/node.js        |  0
 app/routes/{ => authenticated}/roles/add.js   |  7 +--
 app/routes/{ => authenticated}/roles/edit.js  |  6 +-
 app/routes/{ => authenticated}/roles/index.js |  5 +-
 app/routes/{ => authenticated}/tag.js         |  0
 app/routes/{ => authenticated}/tags.js        |  5 +-
 app/routes/{ => authenticated}/users/add.js   |  4 +-
 .../users/change_password.js                  |  6 +-
 app/routes/{ => authenticated}/users/edit.js  |  5 +-
 app/routes/{ => authenticated}/users/index.js |  6 +-
 app/routes/login.js                           |  3 +-
 .../{application.hbs => authenticated.hbs}    |  0
 app/templates/{ => authenticated}/about.hbs   |  0
 .../{ => authenticated}/automates/add.hbs     |  0
 .../automates/automate.hbs                    |  0
 .../{ => authenticated}/automates/index.hbs   |  0
 app/templates/{ => authenticated}/contact.hbs |  0
 .../{ => authenticated}/document.hbs          |  0
 .../{ => authenticated}/documents.hbs         |  0
 app/templates/{ => authenticated}/folder.hbs  |  0
 app/templates/{ => authenticated}/folders.hbs |  0
 app/templates/{ => authenticated}/groups.hbs  |  0
 app/templates/authenticated/guest.hbs         |  2 +
 app/templates/{ => authenticated}/inbox.hbs   |  0
 app/templates/authenticated/index.hbs         |  2 +
 app/templates/{ => authenticated}/node.hbs    |  0
 .../{ => authenticated}/roles/add.hbs         |  0
 .../{ => authenticated}/roles/edit.hbs        |  0
 .../{ => authenticated}/roles/index.hbs       |  2 +-
 app/templates/{ => authenticated}/tags.hbs    |  0
 .../{ => authenticated}/users/add.hbs         |  0
 .../users/change_password.hbs                 |  0
 .../{ => authenticated}/users/edit.hbs        |  0
 .../{ => authenticated}/users/index.hbs       |  2 +-
 app/templates/index.hbs                       |  3 -
 app/templates/login.hbs                       |  6 +-
 50 files changed, 139 insertions(+), 86 deletions(-)
 create mode 100644 app/authenticators/auth-token.js
 delete mode 100644 app/authenticators/oauth2.js
 create mode 100644 app/base/routing.js
 rename app/routes/{ => authenticated}/automates/index.js (56%)
 rename app/routes/{ => authenticated}/document.js (100%)
 rename app/routes/{ => authenticated}/groups.js (57%)
 rename app/routes/{ => authenticated}/index.js (99%)
 rename app/routes/{ => authenticated}/node.js (100%)
 rename app/routes/{ => authenticated}/roles/add.js (57%)
 rename app/routes/{ => authenticated}/roles/edit.js (75%)
 rename app/routes/{ => authenticated}/roles/index.js (82%)
 rename app/routes/{ => authenticated}/tag.js (100%)
 rename app/routes/{ => authenticated}/tags.js (57%)
 rename app/routes/{ => authenticated}/users/add.js (75%)
 rename app/routes/{ => authenticated}/users/change_password.js (55%)
 rename app/routes/{ => authenticated}/users/edit.js (73%)
 rename app/routes/{ => authenticated}/users/index.js (57%)
 rename app/templates/{application.hbs => authenticated.hbs} (100%)
 rename app/templates/{ => authenticated}/about.hbs (100%)
 rename app/templates/{ => authenticated}/automates/add.hbs (100%)
 rename app/templates/{ => authenticated}/automates/automate.hbs (100%)
 rename app/templates/{ => authenticated}/automates/index.hbs (100%)
 rename app/templates/{ => authenticated}/contact.hbs (100%)
 rename app/templates/{ => authenticated}/document.hbs (100%)
 rename app/templates/{ => authenticated}/documents.hbs (100%)
 rename app/templates/{ => authenticated}/folder.hbs (100%)
 rename app/templates/{ => authenticated}/folders.hbs (100%)
 rename app/templates/{ => authenticated}/groups.hbs (100%)
 create mode 100644 app/templates/authenticated/guest.hbs
 rename app/templates/{ => authenticated}/inbox.hbs (100%)
 create mode 100644 app/templates/authenticated/index.hbs
 rename app/templates/{ => authenticated}/node.hbs (100%)
 rename app/templates/{ => authenticated}/roles/add.hbs (100%)
 rename app/templates/{ => authenticated}/roles/edit.hbs (100%)
 rename app/templates/{ => authenticated}/roles/index.hbs (66%)
 rename app/templates/{ => authenticated}/tags.hbs (100%)
 rename app/templates/{ => authenticated}/users/add.hbs (100%)
 rename app/templates/{ => authenticated}/users/change_password.hbs (100%)
 rename app/templates/{ => authenticated}/users/edit.hbs (100%)
 rename app/templates/{ => authenticated}/users/index.hbs (74%)
 delete mode 100644 app/templates/index.hbs

diff --git a/app/app.js b/app/app.js
index 8a1e611..bd4343c 100644
--- a/app/app.js
+++ b/app/app.js
@@ -3,6 +3,7 @@ import Resolver from 'ember-resolver';
 import loadInitializers from 'ember-load-initializers';
 import config from 'papermerge/config/environment';
 
+
 export default class App extends Application {
   modulePrefix = config.modulePrefix;
   podModulePrefix = config.podModulePrefix;
diff --git a/app/authenticators/auth-token.js b/app/authenticators/auth-token.js
new file mode 100644
index 0000000..eb95802
--- /dev/null
+++ b/app/authenticators/auth-token.js
@@ -0,0 +1,35 @@
+import Base from 'ember-simple-auth/authenticators/base';
+
+
+class AuthToken extends Base {
+
+  async authenticate(username, password) {
+    let response, error;
+
+    response = await fetch('http://localhost:8000/api/auth-token/', {
+      'method': 'POST',
+      'headers': {
+        'Content-Type': 'application/json'
+      },
+      body: JSON.stringify({username, password})
+    });
+
+    if (response.ok) {
+      return response.json();
+    } else {
+      error = await response.json();
+      throw new Error(error.non_field_errors[0]);
+    }
+  }
+
+  restore(data) {
+    //pass
+  }
+
+  invalidate(data) {
+    //pass
+  }
+}
+
+
+export default AuthToken;
\ No newline at end of file
diff --git a/app/authenticators/oauth2.js b/app/authenticators/oauth2.js
deleted file mode 100644
index 267cf12..0000000
--- a/app/authenticators/oauth2.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import OAuth2PasswordGrantAuthenticator from 'ember-simple-auth/authenticators/oauth2-password-grant';
-
-
-class OAuth2Authenticator extends OAuth2PasswordGrantAuthenticator {
-  serverTokenEndpoint = '/api/authenticate';
-}
-
-
-export default OAuth2Authenticator;
\ No newline at end of file
diff --git a/app/base/routing.js b/app/base/routing.js
new file mode 100644
index 0000000..35434d0
--- /dev/null
+++ b/app/base/routing.js
@@ -0,0 +1,12 @@
+import Route from '@ember/routing/route';
+import { inject as service } from '@ember/service';
+
+
+export default class BaseRoute extends Route {
+
+  @service session;
+
+  beforeModel(transition) {
+    this.session.requireAuthentication(transition, 'login');
+  }
+}
diff --git a/app/components/nav/sidebar.hbs b/app/components/nav/sidebar.hbs
index 4959626..10cef83 100644
--- a/app/components/nav/sidebar.hbs
+++ b/app/components/nav/sidebar.hbs
@@ -6,37 +6,38 @@
     <hr>
     <ul class="nav nav-pills flex-column mb-auto">
       <li class="nav-item">
-        <LinkTo @route="index" class="nav-link text-white" aria-current="page">
+        <LinkTo @route="authenticated.index" class="nav-link text-white" aria-current="page">
           <i class="bi-folder me-2"></i>Documents
         </LinkTo>
       </li>
       <li>
-        <LinkTo @route="inbox" class="nav-link text-white">
+        <LinkTo @route="authenticated.inbox" class="nav-link text-white">
           <i class="bi-inbox me-2"></i>Inbox
         </LinkTo>
       </li>
+
       <li>
-        <LinkTo @route="automates" class="nav-link text-white">
+        <LinkTo @route="authenticated.automates" class="nav-link text-white">
           <i class="fas fa-robot me-2"></i>Automates
         </LinkTo>
       </li>
       <li>
-        <LinkTo @route="tags" class="nav-link text-white">
+        <LinkTo @route="authenticated.tags" class="nav-link text-white">
           <i class="bi-tag me-2"></i>Tags
         </LinkTo>
       </li>
       <li>
-        <LinkTo @route="groups" class="nav-link text-white">
+        <LinkTo @route="authenticated.groups" class="nav-link text-white">
           <i class="fas fa-users me-2"></i>Groups
         </LinkTo>
       </li>
       <li>
-        <LinkTo @route="users" class="nav-link text-white">
+        <LinkTo @route="authenticated.users" class="nav-link text-white">
           <i class="fas fa-user-friends me-2"></i>Users
         </LinkTo>
       </li>
       <li>
-        <LinkTo @route="roles" class="nav-link text-white">
+        <LinkTo @route="authenticated.roles" class="nav-link text-white">
           <i class="fas fa-user me-2"></i>Roles
         </LinkTo>
       </li>
diff --git a/app/components/role/edit.hbs b/app/components/role/edit.hbs
index 8b286f2..d0e271c 100644
--- a/app/components/role/edit.hbs
+++ b/app/components/role/edit.hbs
@@ -16,5 +16,5 @@
 
 <div class="mb-3">
   <Button::Submit @onClick={{this.onSubmit}} />
-  <Button::Cancel @route="roles"/>
+  <Button::Cancel @route="authenticated.roles"/>
 </div>
\ No newline at end of file
diff --git a/app/components/role/table_row.hbs b/app/components/role/table_row.hbs
index 3e0a816..56bedb7 100644
--- a/app/components/role/table_row.hbs
+++ b/app/components/role/table_row.hbs
@@ -4,7 +4,7 @@
   </td>
   <td>
     <LinkTo
-      @route="roles.edit"
+      @route="authenticated.roles.edit"
       @model={{@role.id}}>Edit</LinkTo>
     <Button::Link
       @text="Remove"
diff --git a/app/components/user/table_row.hbs b/app/components/user/table_row.hbs
index c647eeb..72f2240 100644
--- a/app/components/user/table_row.hbs
+++ b/app/components/user/table_row.hbs
@@ -13,12 +13,12 @@
   </td>
   <td>
     <LinkTo
-      @route="users.edit"
+      @route="authenticated.users.edit"
       @model={{@user.id}}>Edit</LinkTo>
     <Button::Link @text="Remove"
       @onClick={{(fn this.onRemove @user)}} />
     <LinkTo
-      @route="users.change_password"
+      @route="authenticated.users.change_password"
       @model={{@user.id}}>Change Password</LinkTo>
   </td>
 </tr>
\ No newline at end of file
diff --git a/app/controllers/login.js b/app/controllers/login.js
index 8a51a71..7aa2167 100644
--- a/app/controllers/login.js
+++ b/app/controllers/login.js
@@ -15,7 +15,15 @@ export default class LoginController extends Controller {
     let { identification, password } = this;
 
 
-    await this.session.authenticate('authenticator:oauth2', identification, password);
+    try {
+      await this.session.authenticate(
+        'authenticator:auth-token',
+        identification,
+        password
+      );
+    } catch (error) {
+      this.errorMessage = error;
+    }
 
     if (this.session.isAuthenticated) {
       // What to do with all this success?
diff --git a/app/router.js b/app/router.js
index 1dcf684..61086cd 100644
--- a/app/router.js
+++ b/app/router.js
@@ -8,36 +8,38 @@ export default class Router extends EmberRouter {
 
 Router.map(function () {
   this.route('login');
-  
-  this.route('documents');
-  this.route('inbox');
-  this.route('document', { path: '/document/:document_id' });
 
-  this.route('node', { path: '/node/:node_id' });
-
-  this.route('tags');
-
-  this.route('automates', function () {
-    this.route('add');
-    this.route('edit', { path: '/:automate_id/edit' });
-    this.route('index', { path: '/' });
-  });
-
-  this.route('roles', function () {
-    this.route('add');
-    this.route('edit', { path: '/:role_id/edit' });
-    this.route('index', { path: '/' });
-  });
-
-  this.route('users', function () {
-    this.route('add');
-    this.route('edit', { path: '/:user_id/edit' });
-    this.route('change_password', { path: '/:user_id/change-password'});
-    this.route('index', { path: '/' });
-  });
-
-  this.route('groups', function () {
-    this.route('index', { path: '/' });
+  this.route('authenticated', { path: '' }, function() {
+    this.route('documents');
+    this.route('inbox');
+    this.route('document', { path: '/document/:document_id' });
+
+    this.route('node', { path: '/node/:node_id' });
+
+    this.route('tags');
+
+    this.route('automates', function () {
+      this.route('add');
+      this.route('edit', { path: '/:automate_id/edit' });
+      this.route('index', { path: '/' });
+    });
+
+    this.route('roles', function () {
+      this.route('add');
+      this.route('edit', { path: '/:role_id/edit' });
+      this.route('index', { path: '/' });
+    });
+
+    this.route('users', function () {
+      this.route('add');
+      this.route('edit', { path: '/:user_id/edit' });
+      this.route('change_password', { path: '/:user_id/change-password'});
+      this.route('index', { path: '/' });
+    });
+
+    this.route('groups', function () {
+      this.route('index', { path: '/' });
+    });
   });
 
   this.route('not-found', { path: '/*path' });
diff --git a/app/routes/automates/index.js b/app/routes/authenticated/automates/index.js
similarity index 56%
rename from app/routes/automates/index.js
rename to app/routes/authenticated/automates/index.js
index fabb802..9f39aa0 100644
--- a/app/routes/automates/index.js
+++ b/app/routes/authenticated/automates/index.js
@@ -1,7 +1,8 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
+import BaseRoute from 'papermerge/base/routing';
 
-export default class AutomatesRoute extends Route {
+
+export default class AutomatesRoute extends BaseRoute {
   @service store;
 
   async model() {
diff --git a/app/routes/document.js b/app/routes/authenticated/document.js
similarity index 100%
rename from app/routes/document.js
rename to app/routes/authenticated/document.js
diff --git a/app/routes/groups.js b/app/routes/authenticated/groups.js
similarity index 57%
rename from app/routes/groups.js
rename to app/routes/authenticated/groups.js
index 258df0b..1163f4a 100644
--- a/app/routes/groups.js
+++ b/app/routes/authenticated/groups.js
@@ -1,7 +1,8 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
+import BaseRoute from 'papermerge/base/routing'
 
-export default class GroupsRoute extends Route {
+
+export default class GroupsRoute extends BaseRoute {
   @service store;
 
   async model() {
diff --git a/app/routes/index.js b/app/routes/authenticated/index.js
similarity index 99%
rename from app/routes/index.js
rename to app/routes/authenticated/index.js
index 74e0459..781afc2 100644
--- a/app/routes/index.js
+++ b/app/routes/authenticated/index.js
@@ -1,6 +1,7 @@
 import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
 
+
 export default class IndexRoute extends Route {
   @service store;
   async model() {
diff --git a/app/routes/node.js b/app/routes/authenticated/node.js
similarity index 100%
rename from app/routes/node.js
rename to app/routes/authenticated/node.js
diff --git a/app/routes/roles/add.js b/app/routes/authenticated/roles/add.js
similarity index 57%
rename from app/routes/roles/add.js
rename to app/routes/authenticated/roles/add.js
index 50b38dd..5c8578c 100644
--- a/app/routes/roles/add.js
+++ b/app/routes/authenticated/roles/add.js
@@ -1,12 +1,11 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
+import BaseRoute from 'papermerge/base/routing';
 
-class AddRoleRoute extends Route {
+
+export default class AddRoleRoute extends BaseRoute {
   @service store;
 
   async model() {
     return this.store.findAll('permission');
   }
 }
-
-export default AddRoleRoute;
diff --git a/app/routes/roles/edit.js b/app/routes/authenticated/roles/edit.js
similarity index 75%
rename from app/routes/roles/edit.js
rename to app/routes/authenticated/roles/edit.js
index f0e6531..742fbd1 100644
--- a/app/routes/roles/edit.js
+++ b/app/routes/authenticated/roles/edit.js
@@ -1,9 +1,9 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
 import RSVP from 'rsvp';
+import BaseRoute from 'papermerge/base/routing'
 
 
-class EditRoleRoute extends Route {
+export default class EditRoleRoute extends BaseRoute {
   @service store;
 
   async model(params) {
@@ -17,5 +17,3 @@ class EditRoleRoute extends Route {
     });
   }
 }
-
-export default EditRoleRoute;
diff --git a/app/routes/roles/index.js b/app/routes/authenticated/roles/index.js
similarity index 82%
rename from app/routes/roles/index.js
rename to app/routes/authenticated/roles/index.js
index 7cd3825..d20a63d 100644
--- a/app/routes/roles/index.js
+++ b/app/routes/authenticated/roles/index.js
@@ -1,7 +1,8 @@
 import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
 
-class RolesRoute extends Route {
+
+export default class RolesRoute extends Route {
   @service store;
   @service session;
 
@@ -13,5 +14,3 @@ class RolesRoute extends Route {
     return this.store.findAll('role');
   }
 }
-
-export default RolesRoute;
diff --git a/app/routes/tag.js b/app/routes/authenticated/tag.js
similarity index 100%
rename from app/routes/tag.js
rename to app/routes/authenticated/tag.js
diff --git a/app/routes/tags.js b/app/routes/authenticated/tags.js
similarity index 57%
rename from app/routes/tags.js
rename to app/routes/authenticated/tags.js
index 615910e..67f9b06 100644
--- a/app/routes/tags.js
+++ b/app/routes/authenticated/tags.js
@@ -1,7 +1,8 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
+import BaseRoute from 'papermerge/base/routing';
 
-export default class TagsRoute extends Route {
+
+export default class TagsRoute extends BaseRoute {
   @service store;
 
   async model() {
diff --git a/app/routes/users/add.js b/app/routes/authenticated/users/add.js
similarity index 75%
rename from app/routes/users/add.js
rename to app/routes/authenticated/users/add.js
index 9f83015..ad858ea 100644
--- a/app/routes/users/add.js
+++ b/app/routes/authenticated/users/add.js
@@ -1,9 +1,9 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
 import RSVP from 'rsvp';
+import BaseRoute from 'papermerge/base/routing';
 
 
-class AddUserRoute extends Route {
+class AddUserRoute extends BaseRoute {
   @service store;
 
   async model() {
diff --git a/app/routes/users/change_password.js b/app/routes/authenticated/users/change_password.js
similarity index 55%
rename from app/routes/users/change_password.js
rename to app/routes/authenticated/users/change_password.js
index be3062f..da9cdc9 100644
--- a/app/routes/users/change_password.js
+++ b/app/routes/authenticated/users/change_password.js
@@ -1,13 +1,11 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
+import BaseRoute from 'papermerge/base/routing'
 
 
-class ChangeUserPasswordRoute extends Route {
+export default class ChangeUserPasswordRoute extends BaseRoute {
   @service store;
 
   async model(params) {
     return this.store.findRecord('user', params.user_id);
   }
 }
-
-export default ChangeUserPasswordRoute;
diff --git a/app/routes/users/edit.js b/app/routes/authenticated/users/edit.js
similarity index 73%
rename from app/routes/users/edit.js
rename to app/routes/authenticated/users/edit.js
index fa2da1e..3ad9e43 100644
--- a/app/routes/users/edit.js
+++ b/app/routes/authenticated/users/edit.js
@@ -1,9 +1,9 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
 import RSVP from 'rsvp';
+import BaseRoute from 'papermerge/base/routing'
 
 
-class EditUserRoute extends Route {
+export default class EditUserRoute extends BaseRoute {
   @service store;
 
   async model(params) {
@@ -15,4 +15,3 @@ class EditUserRoute extends Route {
   }
 }
 
-export default EditUserRoute;
diff --git a/app/routes/users/index.js b/app/routes/authenticated/users/index.js
similarity index 57%
rename from app/routes/users/index.js
rename to app/routes/authenticated/users/index.js
index 5088d42..e09404b 100644
--- a/app/routes/users/index.js
+++ b/app/routes/authenticated/users/index.js
@@ -1,7 +1,8 @@
-import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
+import BaseRoute from 'papermerge/base/routing';
 
-class UsersRoute extends Route {
+
+export default class UsersRoute extends BaseRoute {
   @service store;
 
   async model() {
@@ -9,4 +10,3 @@ class UsersRoute extends Route {
   }
 }
 
-export default UsersRoute;
diff --git a/app/routes/login.js b/app/routes/login.js
index c9cfd7d..049b8a6 100644
--- a/app/routes/login.js
+++ b/app/routes/login.js
@@ -1,10 +1,11 @@
 import Route from '@ember/routing/route';
 import { inject as service } from '@ember/service';
 
+
 export default class LoginRoute extends Route {
   @service session;
 
   beforeModel(transition) {
-    this.get('session').prohibitAuthentication('index');
+    this.get('session').prohibitAuthentication('roles');
   }
 }
\ No newline at end of file
diff --git a/app/templates/application.hbs b/app/templates/authenticated.hbs
similarity index 100%
rename from app/templates/application.hbs
rename to app/templates/authenticated.hbs
diff --git a/app/templates/about.hbs b/app/templates/authenticated/about.hbs
similarity index 100%
rename from app/templates/about.hbs
rename to app/templates/authenticated/about.hbs
diff --git a/app/templates/automates/add.hbs b/app/templates/authenticated/automates/add.hbs
similarity index 100%
rename from app/templates/automates/add.hbs
rename to app/templates/authenticated/automates/add.hbs
diff --git a/app/templates/automates/automate.hbs b/app/templates/authenticated/automates/automate.hbs
similarity index 100%
rename from app/templates/automates/automate.hbs
rename to app/templates/authenticated/automates/automate.hbs
diff --git a/app/templates/automates/index.hbs b/app/templates/authenticated/automates/index.hbs
similarity index 100%
rename from app/templates/automates/index.hbs
rename to app/templates/authenticated/automates/index.hbs
diff --git a/app/templates/contact.hbs b/app/templates/authenticated/contact.hbs
similarity index 100%
rename from app/templates/contact.hbs
rename to app/templates/authenticated/contact.hbs
diff --git a/app/templates/document.hbs b/app/templates/authenticated/document.hbs
similarity index 100%
rename from app/templates/document.hbs
rename to app/templates/authenticated/document.hbs
diff --git a/app/templates/documents.hbs b/app/templates/authenticated/documents.hbs
similarity index 100%
rename from app/templates/documents.hbs
rename to app/templates/authenticated/documents.hbs
diff --git a/app/templates/folder.hbs b/app/templates/authenticated/folder.hbs
similarity index 100%
rename from app/templates/folder.hbs
rename to app/templates/authenticated/folder.hbs
diff --git a/app/templates/folders.hbs b/app/templates/authenticated/folders.hbs
similarity index 100%
rename from app/templates/folders.hbs
rename to app/templates/authenticated/folders.hbs
diff --git a/app/templates/groups.hbs b/app/templates/authenticated/groups.hbs
similarity index 100%
rename from app/templates/groups.hbs
rename to app/templates/authenticated/groups.hbs
diff --git a/app/templates/authenticated/guest.hbs b/app/templates/authenticated/guest.hbs
new file mode 100644
index 0000000..b499aec
--- /dev/null
+++ b/app/templates/authenticated/guest.hbs
@@ -0,0 +1,2 @@
+Guest
+{{main}}
diff --git a/app/templates/inbox.hbs b/app/templates/authenticated/inbox.hbs
similarity index 100%
rename from app/templates/inbox.hbs
rename to app/templates/authenticated/inbox.hbs
diff --git a/app/templates/authenticated/index.hbs b/app/templates/authenticated/index.hbs
new file mode 100644
index 0000000..dc58275
--- /dev/null
+++ b/app/templates/authenticated/index.hbs
@@ -0,0 +1,2 @@
+<Breadcrumb />
+<Nodes @nodes={{@model}} />
\ No newline at end of file
diff --git a/app/templates/node.hbs b/app/templates/authenticated/node.hbs
similarity index 100%
rename from app/templates/node.hbs
rename to app/templates/authenticated/node.hbs
diff --git a/app/templates/roles/add.hbs b/app/templates/authenticated/roles/add.hbs
similarity index 100%
rename from app/templates/roles/add.hbs
rename to app/templates/authenticated/roles/add.hbs
diff --git a/app/templates/roles/edit.hbs b/app/templates/authenticated/roles/edit.hbs
similarity index 100%
rename from app/templates/roles/edit.hbs
rename to app/templates/authenticated/roles/edit.hbs
diff --git a/app/templates/roles/index.hbs b/app/templates/authenticated/roles/index.hbs
similarity index 66%
rename from app/templates/roles/index.hbs
rename to app/templates/authenticated/roles/index.hbs
index 0bb7844..b527810 100644
--- a/app/templates/roles/index.hbs
+++ b/app/templates/authenticated/roles/index.hbs
@@ -1,4 +1,4 @@
-<Button::New @route="roles.add" class="roles-add"/>
+<Button::New @route="authenticated.roles.add" class="roles-add"/>
 
 <Table @titles={{array 'title' 'action'}}>
   {{#each @model as |role|}}
diff --git a/app/templates/tags.hbs b/app/templates/authenticated/tags.hbs
similarity index 100%
rename from app/templates/tags.hbs
rename to app/templates/authenticated/tags.hbs
diff --git a/app/templates/users/add.hbs b/app/templates/authenticated/users/add.hbs
similarity index 100%
rename from app/templates/users/add.hbs
rename to app/templates/authenticated/users/add.hbs
diff --git a/app/templates/users/change_password.hbs b/app/templates/authenticated/users/change_password.hbs
similarity index 100%
rename from app/templates/users/change_password.hbs
rename to app/templates/authenticated/users/change_password.hbs
diff --git a/app/templates/users/edit.hbs b/app/templates/authenticated/users/edit.hbs
similarity index 100%
rename from app/templates/users/edit.hbs
rename to app/templates/authenticated/users/edit.hbs
diff --git a/app/templates/users/index.hbs b/app/templates/authenticated/users/index.hbs
similarity index 74%
rename from app/templates/users/index.hbs
rename to app/templates/authenticated/users/index.hbs
index 22cb1f7..6184fb6 100644
--- a/app/templates/users/index.hbs
+++ b/app/templates/authenticated/users/index.hbs
@@ -1,4 +1,4 @@
-<Button::New @route="users.add" class="users-add"/>
+<Button::New @route="authenticated.users.add" class="users-add"/>
 
 <Table @titles={{array
     'username'
diff --git a/app/templates/index.hbs b/app/templates/index.hbs
deleted file mode 100644
index fbf2b1f..0000000
--- a/app/templates/index.hbs
+++ /dev/null
@@ -1,3 +0,0 @@
-
-<Breadcrumb />
-<Nodes @nodes={{@model}} />
diff --git a/app/templates/login.hbs b/app/templates/login.hbs
index 5f0944e..1c60b22 100644
--- a/app/templates/login.hbs
+++ b/app/templates/login.hbs
@@ -1,10 +1,14 @@
 <form {{on "submit" this.authenticate}}>
+
   <label for="identification">Login</label>
   <input id='identification' placeholder="Enter Login" value={{this.identification}} {{on "change" this.updateIdentification}}>
+
   <label for="password">Password</label>
   <input id='password' placeholder="Enter Password" value={{this.password}} {{on "change" this.updatePassword}}>
+
   <button type="submit">Login</button>
   {{#if this.errorMessage}}
     <p>{{this.errorMessage}}</p>
   {{/if}}
-</form>
\ No newline at end of file
+
+</form>
-- 
GitLab