diff --git a/app/authenticators/jwt-resolved.js b/app/authenticators/jwt-resolved.js new file mode 100644 index 0000000..a6884ec --- /dev/null +++ b/app/authenticators/jwt-resolved.js @@ -0,0 +1,18 @@ +import Ember from 'ember'; +import JwtTokenAuthenticator from 'simple-auth-token/authenticators/jwt'; + +export default JwtTokenAuthenticator.extend({ + authenticate: function(token) { + return new Ember.RSVP.Promise(resolve => { + let tokenData = this.getTokenData(token); + let expiresAt = tokenData[this.tokenExpireName]; + let response = {}; + response[this.tokenPropertyName] = token; + response.expiresAt = expiresAt; + this.scheduleAccessTokenRefresh(expiresAt, token); + + resolve(this.getResponseData(response)); + }); + }, + +}); diff --git a/app/pods/components/x-application/template.hbs b/app/pods/components/x-application/template.hbs index 04d7ca2..635b605 100644 --- a/app/pods/components/x-application/template.hbs +++ b/app/pods/components/x-application/template.hbs @@ -30,6 +30,8 @@ {{link-to 'Login' 'login'}}
{{link-to 'Sign Up' 'users.new'}} +
+ {{link-to 'Locked Out?' 'users.requestlockouthelp'}}

{{/if}} diff --git a/app/pods/login/template.hbs b/app/pods/login/template.hbs index 8f07896..7d3f5ac 100644 --- a/app/pods/login/template.hbs +++ b/app/pods/login/template.hbs @@ -8,5 +8,9 @@ {{input value=password type="password" placeholder="Password"}} {{input class="button-gray" type="submit" value="Log In"}} +
+
+ Forget your password? {{link-to 'Request a lockout email.' 'users.requestlockouthelp'}} +
{{/if}} {{/x-application}} diff --git a/app/pods/users/lockoutauthenticate/controller.js b/app/pods/users/lockoutauthenticate/controller.js new file mode 100644 index 0000000..79734b5 --- /dev/null +++ b/app/pods/users/lockoutauthenticate/controller.js @@ -0,0 +1,6 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + queryParams: ['token'], + +}); diff --git a/app/pods/users/lockoutauthenticate/route.js b/app/pods/users/lockoutauthenticate/route.js new file mode 100644 index 0000000..131628c --- /dev/null +++ b/app/pods/users/lockoutauthenticate/route.js @@ -0,0 +1,9 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + beforeModel: function(transition) { + let token = Ember.get(transition, 'queryParams.token'); + this.get('session').authenticate('authenticator:jwt-resolved', token); + }, + +}); diff --git a/app/pods/users/requestlockouthelp/controller.js b/app/pods/users/requestlockouthelp/controller.js new file mode 100644 index 0000000..205f73c --- /dev/null +++ b/app/pods/users/requestlockouthelp/controller.js @@ -0,0 +1,19 @@ +import Ember from 'ember'; +import ajaxRequest from '../../../utils/ajax-request'; + +export default Ember.Controller.extend({ + actions: { + save: function() { + let url = `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/users/lockout`; + let options = { + method: 'POST', + data: { email: this.get('email') }, + }; + ajaxRequest(url, options); + this.transitionTo('login'); + this.get('flashMessages').information('Please check your email'); + }, + + }, + +}); diff --git a/app/pods/users/requestlockouthelp/route.js b/app/pods/users/requestlockouthelp/route.js new file mode 100644 index 0000000..19831b4 --- /dev/null +++ b/app/pods/users/requestlockouthelp/route.js @@ -0,0 +1,8 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + deactivate: function() { + this.controller.set('email', null); + }, + +}); diff --git a/app/pods/users/requestlockouthelp/template.hbs b/app/pods/users/requestlockouthelp/template.hbs new file mode 100644 index 0000000..f348427 --- /dev/null +++ b/app/pods/users/requestlockouthelp/template.hbs @@ -0,0 +1,18 @@ +
+
+
+ Account Lockout Access +
+
    +
  • + + {{input value=email}} +
  • +
  • + +
  • +
+
+
+
+
diff --git a/app/router.js b/app/router.js index 3dc92aa..c34e885 100644 --- a/app/router.js +++ b/app/router.js @@ -9,6 +9,8 @@ Router.map(function() { this.route('login'); this.route('users', function() { + this.route('requestlockouthelp'); + this.route('lockoutauthenticate'); this.route('new', function() { this.route('verify', { path: 'verify/:nonce' }); });