File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import Ember from 'ember' ;
2+
3+ export default {
4+ name : 'init-shared' ,
5+ after : 'simple-auth' ,
6+ initialize : function ( container ) {
7+ var sharedStore = Ember . Object . create ( { } ) ;
8+ container . optionsForType ( 'globals' , { instantiate : false , singleton : true } ) ;
9+ container . register ( 'globals:shared' , sharedStore ) ;
10+ container . typeInjection ( 'controller' , 'shared' , 'globals:shared' ) ;
11+ container . typeInjection ( 'route' , 'shared' , 'globals:shared' ) ;
12+ }
13+ } ;
Original file line number Diff line number Diff line change 1+ import Ember from 'ember' ;
2+
3+ export default {
4+ name : 'user-in-route' ,
5+ after : 'store' ,
6+ initialize : function ( container ) {
7+ var session = container . lookup ( 'simple-auth-session:main' ) ;
8+
9+ var observer = Ember . Object . extend ( {
10+ observerForSession : function ( ) {
11+ var self = this ;
12+ if ( this . get ( 'session.user_email' ) ) {
13+ container . lookup ( 'store:main' ) . find ( 'user' , 'admin' ) . then ( function ( user ) {
14+ container . lookup ( 'globals:shared' ) . set ( 'currentUser' , user ) ;
15+ } , function ( ) {
16+ self . get ( 'session' ) . invalidate ( ) . then ( function ( ) {
17+ localStorage . removeItem ( 'ember_simple_auth:session' ) ;
18+ } ) ;
19+ } ) ;
20+ }
21+ } . observes ( 'session.user_email' ) . on ( 'init' )
22+ } ) ;
23+ observer . create ( { session : session } ) ;
24+ }
25+ } ;
Original file line number Diff line number Diff line change 1+ import Ember from 'ember' ;
2+ import authMixin from 'simple-auth/mixins/application-route-mixin' ;
3+ var loginRoute = Ember . Route . extend ( authMixin , {
4+ redirect : function ( ) {
5+ if ( this . get ( 'session.isAuthenticated' ) ) {
6+ this . transitionTo ( '/' ) ;
7+ }
8+ } ,
9+
10+ renderTemplate : function ( ) {
11+ this . render ( 'login' , { outlet : 'login' } ) ;
12+ }
13+ } ) ;
14+ export default loginRoute ;
Original file line number Diff line number Diff line change 1+ <div class =" container main" >
2+ <div class =" col-md-4 col-md-offset-3" >
3+ <h1 >Login</h1 >
4+ <form {{ action ' authenticate' on =' submit' }} class =" form-horizontal" role =" form" >
5+ <div class =" form-group" >
6+ <label for =" identification" >Login</label >
7+ {{ input value =identification placeholder =' Enter Login' class =" form-control" }}
8+ </div >
9+ <div class =" form-group" >
10+ <label for =" password" >Password</label >
11+ {{ input value =password placeholder =' Enter Password' type =' password' class =" form-control" }}
12+ </div >
13+ <button type =" submit" class =" btn btn-success form-control" >Login</button >
14+ </form >
15+ </div >
16+ </div >
Original file line number Diff line number Diff line change 11{
22 "name" : " ember-cli-admin-auth" ,
3- "version" : " 0.0.0 " ,
3+ "version" : " 0.0.1 " ,
44 "description" : " The default blueprint for ember-cli addons." ,
55 "directories" : {
66 "doc" : " doc" ,
You can’t perform that action at this time.
0 commit comments