This repository has been archived by the owner on Oct 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Reset2FA): form to reset two step verification
- Loading branch information
Showing
9 changed files
with
199 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
.pos-rel(ng-switch="currentStep") | ||
header.flex-center.flex-between | ||
.flex-column | ||
h2.em-300.mtn(translate="RESET_2FA") | ||
p(translate="RESET_2FA_HELP_1", ng-switch-when="1") | ||
p(translate="RESET_2FA_HELP_2", ng-switch-when="1") | ||
form.ptl.form-horizontal(name="form" autocomplete="off" novalidate) | ||
div(ng-switch-when="1") | ||
.form-group(ng-class="{'has-error': form.uid.$invalid && form.uid.$touched}") | ||
label(translate="RESET_2FA_WALLET_IDENTIFIER") | ||
input.form-control( | ||
name="uid" | ||
ng-model="fields.uid" | ||
required) | ||
p.help-block | ||
span(translate="RESET_2FA_WALLET_IDENTIFIER_EXPLAIN") | ||
span | ||
a(ui-sref="public.reminder", translate="LOOK_IT_UP_HERE") | ||
span . | ||
.form-group(ng-class="{'has-error': form.email.$invalid && form.email.$touched}") | ||
label(translate="RESET_2FA_REGISTERED_EMAIL") | ||
input.form-control( | ||
type="email" | ||
name="email" | ||
ng-model="fields.email" | ||
placeholder="{{ 'OPTIONAL' | translate }}") | ||
p.help-block(translate="RESET_2FA_REGISTERED_EMAIL_EXPLAIN") | ||
.form-group(ng-class="{'has-error': form.newEmail.$invalid && form.newEmail.$touched}") | ||
label(translate="RESET_2FA_NEW_EMAIL") | ||
input.form-control( | ||
type="email" | ||
name="newEmail" | ||
ng-model="fields.newEmail" | ||
placeholder="{{ 'OPTIONAL' | translate }}") | ||
p.help-block(translate="RESET_2FA_NEW_EMAIL_EXPLAIN") | ||
.form-group(ng-class="{'has-error': form.secret.$invalid && form.secret.$touched}") | ||
label(translate="RESET_2FA_SECRET_PHRASE") | ||
input.form-control( | ||
name="secret" | ||
ng-model="fields.secret" | ||
placeholder="{{ 'OPTIONAL' | translate }}") | ||
p.help-block(translate="RESET_2FA_SECRET_PHRASE_EXPLAIN") | ||
.form-group(ng-class="{'has-error': form.message.$invalid && form.message.$touched}") | ||
label(translate="RESET_2FA_MESSAGE") | ||
textarea.form-control( | ||
name="message" | ||
ng-model="fields.message" | ||
placeholder="{{ 'OPTIONAL' | translate }}") | ||
p.help-block(translate="RESET_2FA_MESSAGE_EXPLAIN") | ||
.form-group(ng-class="{'has-error': form.captcha.$invalid && form.captcha.$touched}") | ||
label(translate="CAPTCHA") | ||
p(translate="CAPTCHA_EXPAIN") | ||
img.mbl(ng-src="{{captchaSrc}}") | ||
input.form-control( | ||
type="text" | ||
name="captcha" | ||
ng-model="fields.captcha" | ||
required) | ||
.flex-center.flex-end.mvl(ng-switch-when="1") | ||
img(ng-show="working" src="img/spinner.gif") | ||
button.button-muted.mrm( | ||
type="button" | ||
ng-disabled="working" | ||
ui-sref="public.help" | ||
translate="GO_BACK") | ||
button.button-success( | ||
type="submit" | ||
ng-click="resetTwoFactor()" | ||
ng-disabled="!form.$valid || working" | ||
translate="CONTINUE") | ||
.flex-center.flex-justify.flex-column(ng-switch-when="2") | ||
.level-complete.flex-center.flex-justify | ||
i.ti-check.bright-green | ||
h4.em-300.mtl(translate="SUCCESS") | ||
p.em-300(translate="RESET_2FA_SUCCESS") | ||
.flex-end | ||
button.button-muted.mrm( | ||
type="button" | ||
ui-sref="public.login-no-uid" | ||
translate="CONTINUE_TO_LOGIN") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
angular | ||
.module('walletApp') | ||
.controller('ResetTwoFactorCtrl', ResetTwoFactorCtrl); | ||
|
||
function ResetTwoFactorCtrl($scope, $rootScope, $http, $translate, Wallet, Alerts) { | ||
|
||
$scope.currentStep = 1; | ||
$scope.fields = { | ||
uid: $rootScope.loginFormUID, | ||
email: '', | ||
newEmail: '', | ||
secret: '', | ||
message: '', | ||
captcha: '' | ||
}; | ||
|
||
$scope.refreshCaptcha = () => { | ||
let time = new Date().getTime(); | ||
$scope.captchaSrc = $rootScope.rootURL + `kaptcha.jpg?timestamp=${time}`; | ||
$scope.fields.captcha = ''; | ||
}; | ||
|
||
$scope.resetTwoFactor = () => { | ||
$scope.working = true; | ||
let success = (res) => { | ||
$scope.working = false; | ||
$scope.currentStep = 2; | ||
}; | ||
let error = (e) => { | ||
$scope.working = false; | ||
$scope.refreshCaptcha(); | ||
}; | ||
|
||
$scope.form.$setPristine(); | ||
$scope.form.$setUntouched(); | ||
|
||
Wallet.requestTwoFactorReset( | ||
$scope.fields.uid, | ||
$scope.fields.email, | ||
$scope.fields.newEmail, | ||
$scope.fields.secret, | ||
$scope.fields.message, | ||
$scope.fields.captcha, | ||
success, | ||
error) | ||
}; | ||
|
||
// Set SID cookie by requesting headers | ||
$http({ | ||
url: $rootScope.rootURL + 'wallet/login', | ||
method: 'HEAD', | ||
withCredentials: true | ||
}).then($scope.refreshCaptcha); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters