Skip to content
Permalink
Browse files
workin towards auth
  • Loading branch information
steveklabnik committed Jul 11, 2015
1 parent dee515c commit 1c51ef4e9db8e03883da619d7c7cdd9694b9c7a0
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 6 deletions.
@@ -0,0 +1,12 @@
import Ember from 'ember';

export default Ember.Controller.extend({
actions: {
authenticate: function() {
var credentials = this.getProperties('identification', 'password'),
authenticator = 'simple-auth-authenticator:jwt';

this.get('session').authenticate(authenticator, credentials);
}
}
});
@@ -10,6 +10,8 @@ Router.map(function() {
this.route('new');
});
this.route('login', { path: '/login' });
this.route('signup', { path: '/signup' });
this.route('auth', { path: '/auth' });
});

export default Router;
@@ -0,0 +1,10 @@
import Ember from 'ember';
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin, {
actions: {
invalidateSession: function() {
this.get('session').invalidate();
}
}
});
@@ -0,0 +1,4 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin);
@@ -1,14 +1,14 @@
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h2>Login</h2>
<form action="/login" method="post">
<form {{action "authenticate" on="submit"}}>
<div class="form-group">
<label for="emailInput">Email:</label>
<input class="form-control" type="text" name="email" id="emailInput"/>
<label for="identification">Email:</label>
{{input id="identification" class="form-control" placeholder="Enter Login" value=identification}}
</div>
<div class="form-group">
<label for="passwordInput">Password:</label>
<input class="form-control" type="password" name="password" id="passwordInput"/>
<label for="password">Password</label>
{{input id='password' class="form-control" placeholder='Enter Password' type='password' value=password}}
</div>
<button class="btn btn-primary" type="submit">Login</button>
</form>
@@ -23,7 +23,12 @@
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<li>{{#link-to 'login'}}Login{{/link-to}}</li>
{{#if session.isAuthenticated}}
<li><a {{ action 'invalidateSession' }}>Logout</a></li>
{{else}}
<li>{{#link-to 'login'}}Log in{{/link-to}}</li>
<li>{{#link-to 'signup'}}Sign up{{/link-to}}</li>
{{/if}}
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
@@ -24,6 +24,12 @@ module.exports = function(environment) {
APP: {
// Here you can pass flags/options to your application instance
// when it is created
},
'simple-auth': {
authorizer: 'simple-auth-authorizer:token'
},
'simple-auth-token': {
serverTokenEndpoint: '/auth'

This comment has been minimized.

Copy link
@MattMSumner

MattMSumner Jul 11, 2015

You could try putting a full url here to have it hit your server. Be sure to checkout https://github.com/simplabs/ember-simple-auth#cross-origin-authorization to make sure you whitelist your backend.

This comment has been minimized.

Copy link
@steveklabnik

steveklabnik Jul 11, 2015

Author Owner

Ahhhh this makes perfect sense, thank you.

}
};

0 comments on commit 1c51ef4

Please sign in to comment.