Skip to content

Commit

Permalink
#3 Complete password implemented. Still needs testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
nadnoslen committed Jan 25, 2019
1 parent fafdbf6 commit 5eb12bc
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
13 changes: 13 additions & 0 deletions app/routes/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-

export default Route.extend(UnauthenticatedRouteMixin, {
actions: {
completePassword(authenticationState, newPassword) {
this.get('session')
.completePassword(authenticationState, newPassword)
.then(authenticationState => {
if (authenticationState.get('mfaRequired?')) {
set(this, 'controller.model.authenticationState', authenticationState);
}
})
.catch(response => this.get('notify').error(response.message));
return false;
},

confirmSignIn(authenticationState, code) {
this.get('session')
.confirmSignIn(authenticationState, code)
Expand Down Expand Up @@ -34,6 +46,7 @@ export default Route.extend(UnauthenticatedRouteMixin, {
return {
authenticationState: {}, // will be set during sign in if MFA is enabled
mfaCode: '',
newPassword: '',
password: '',
username: isNone(get(params, 'username')) ? '' : get(params, 'username')
}
Expand Down
39 changes: 39 additions & 0 deletions app/templates/login.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,45 @@
</button>
</div>
</form>
{{else if model.authenticationState.newPasswordRequired?}}
<legend>Set Your Password</legend>
{{!-- --------------------------------------------------------------------------- Complete New Password --}}
<form class="form"
onsubmit={{action (route-action "completePassword" model.authenticationState model.newPassword)}}>
<div class="form-group d-none">
<label for="js-username-new-password" class="control-label">Email Address</label>
{{input-text
aria-describedby="js-username-new-password-help"
autocomplete="email"
autofocus=true
class="form-control"
id="js-username-new-password"
placeholder="Email Adddress"
type="email"
value=model.username
}}
<small id="js-username-new-password-help" class="form-text text-muted">Your email address.</small>
</div>
<div class="form-group">
<label for="js-password-new-password" class="control-label">New Password</label>
{{input-text
aria-describedby="js-password-new-password-help"
autocomplete="new-password"
class="form-control"
placeholder="Password"
type="password"
value=model.newPassword
}}
<small id="js-password-new-password-help" class="form-text text-muted">
Please choose your new password because that original one we gave you was gnarley!
</small>
</div>
<div class="form-group text-right">
<button class="btn btn-outline-primary" type="submit">
Submit
</button>
</div>
</form>
{{else}}
<legend>Sign In</legend>
{{!-- ------------------------------------------------------------------------------------ Sign In Form --}}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"ember-resolver": "^5.0.1",
"ember-route-action-helper": "^2.0.6",
"ember-simple-auth": "^1.8.0",
"ember-simple-auth-aws-amplify": "^0.1.0-alpha.7",
"ember-simple-auth-aws-amplify": "^0.1.0-alpha.8",
"ember-source": "~3.4.0",
"ember-welcome-page": "^3.2.0",
"eslint-plugin-ember": "^5.2.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4668,10 +4668,10 @@ ember-router-generator@^1.2.3:
dependencies:
recast "^0.11.3"

ember-simple-auth-aws-amplify@^0.1.0-alpha.7:
version "0.1.0-alpha.7"
resolved "https://registry.yarnpkg.com/ember-simple-auth-aws-amplify/-/ember-simple-auth-aws-amplify-0.1.0-alpha.7.tgz#7c4fd4a4052de3ddcee1b6032b3a473a37451baa"
integrity sha512-Gb3ExOw/FHZzQWJUdLy2rdGVSeH9ek/MYMPWxVua/TfDI2IgcoCgBkU7+VpDlv+V0PSSqeIpxzmLzW5FttoyTQ==
ember-simple-auth-aws-amplify@^0.1.0-alpha.8:
version "0.1.0-alpha.8"
resolved "https://registry.yarnpkg.com/ember-simple-auth-aws-amplify/-/ember-simple-auth-aws-amplify-0.1.0-alpha.8.tgz#7b5010a08b7be0f28eb001069ed196eb1db01aec"
integrity sha512-snPU1ZsOWpSM1cdHMBgVqwGHDwVppZGcpumRgVk9bILY67Km3Bcc1WMs60xIUJ8fE2LJL3LbWJ9GQdF0wNKw2Q==
dependencies:
"@aws-amplify/auth" "^1.2.14"
"@aws-amplify/core" "^1.0.21"
Expand Down

0 comments on commit 5eb12bc

Please sign in to comment.