Mfa wip
This commit is contained in:
33
app/assets/javascripts/app/frontend/models/api/mfa.js
Normal file
33
app/assets/javascripts/app/frontend/models/api/mfa.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
class Mfa extends Item {
|
||||||
|
|
||||||
|
constructor(json_obj) {
|
||||||
|
super(json_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
mapContentToLocalProperties(content) {
|
||||||
|
super.mapContentToLocalProperties(content)
|
||||||
|
this.name = content.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
structureParams() {
|
||||||
|
var params = {
|
||||||
|
name: this.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
_.merge(params, super.structureParams());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
toJSON() {
|
||||||
|
return {uuid: this.uuid}
|
||||||
|
}
|
||||||
|
|
||||||
|
get content_type() {
|
||||||
|
return "SN|MFA";
|
||||||
|
}
|
||||||
|
|
||||||
|
doNotEncrypt() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -117,7 +117,7 @@ angular.module('app.frontend')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.login = function(url, email, password, ephemeral, callback) {
|
this.login = function(url, email, password, ephemeral, extraParams, callback) {
|
||||||
this.getAuthParamsForEmail(url, email, function(authParams){
|
this.getAuthParamsForEmail(url, email, function(authParams){
|
||||||
|
|
||||||
if(!authParams || !authParams.pw_cost) {
|
if(!authParams || !authParams.pw_cost) {
|
||||||
@@ -150,7 +150,7 @@ angular.module('app.frontend')
|
|||||||
Neeto.crypto.computeEncryptionKeysForUser(_.merge({password: password}, authParams), function(keys){
|
Neeto.crypto.computeEncryptionKeysForUser(_.merge({password: password}, authParams), function(keys){
|
||||||
|
|
||||||
var requestUrl = url + "/auth/sign_in";
|
var requestUrl = url + "/auth/sign_in";
|
||||||
var params = {password: keys.pw, email: email};
|
var params = _.merge({password: keys.pw, email: email}, extraParams);
|
||||||
httpManager.postAbsolute(requestUrl, params, function(response){
|
httpManager.postAbsolute(requestUrl, params, function(response){
|
||||||
this.setEphemeral(ephemeral);
|
this.setEphemeral(ephemeral);
|
||||||
this.handleAuthResponse(response, email, url, authParams, keys);
|
this.handleAuthResponse(response, email, url, authParams, keys);
|
||||||
|
|||||||
@@ -89,6 +89,12 @@ class AccountMenu {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.submitMfaForm = function() {
|
||||||
|
var params = {};
|
||||||
|
params[$scope.formData.mfa.payload.mfa_key] = $scope.formData.userMfaCode;
|
||||||
|
$scope.login(params);
|
||||||
|
}
|
||||||
|
|
||||||
$scope.submitAuthForm = function() {
|
$scope.submitAuthForm = function() {
|
||||||
if($scope.formData.showLogin) {
|
if($scope.formData.showLogin) {
|
||||||
$scope.login();
|
$scope.login();
|
||||||
@@ -97,19 +103,25 @@ class AccountMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.login = function() {
|
$scope.login = function(extraParams) {
|
||||||
$scope.formData.status = "Generating Login Keys...";
|
$scope.formData.status = "Generating Login Keys...";
|
||||||
$timeout(function(){
|
$timeout(function(){
|
||||||
authManager.login($scope.formData.url, $scope.formData.email, $scope.formData.user_password, $scope.formData.ephemeral, function(response){
|
authManager.login($scope.formData.url, $scope.formData.email, $scope.formData.user_password, $scope.formData.ephemeral, extraParams,
|
||||||
if(!response || response.error) {
|
(response) => {
|
||||||
$scope.formData.status = null;
|
if(!response || response.error) {
|
||||||
var error = response ? response.error : {message: "An unknown error occured."}
|
$scope.formData.status = null;
|
||||||
if(!response || (response && !response.didDisplayAlert)) {
|
var error = response ? response.error : {message: "An unknown error occured."}
|
||||||
alert(error.message);
|
if(error.tag == "mfa-required") {
|
||||||
|
$timeout(() => {
|
||||||
|
$scope.formData.showLogin = false;
|
||||||
|
$scope.formData.mfa = error;
|
||||||
|
})
|
||||||
|
} else if(!response || (response && !response.didDisplayAlert)) {
|
||||||
|
alert(error.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$scope.onAuthSuccess();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$scope.onAuthSuccess();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class ModelManager {
|
|||||||
this._extensions = [];
|
this._extensions = [];
|
||||||
this.acceptableContentTypes = [
|
this.acceptableContentTypes = [
|
||||||
"Note", "Tag", "Extension", "SN|Editor", "SN|Theme",
|
"Note", "Tag", "Extension", "SN|Editor", "SN|Theme",
|
||||||
"SN|Component", "SF|Extension", "SN|UserPreferences"
|
"SN|Component", "SF|Extension", "SN|UserPreferences", "SF|MFA"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +211,8 @@ class ModelManager {
|
|||||||
item = new Component(json_obj);
|
item = new Component(json_obj);
|
||||||
} else if(json_obj.content_type == "SF|Extension") {
|
} else if(json_obj.content_type == "SF|Extension") {
|
||||||
item = new SyncAdapter(json_obj);
|
item = new SyncAdapter(json_obj);
|
||||||
|
} else if(json_obj.content_type == "SF|MFA") {
|
||||||
|
item = new Mfa(json_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
-# Account Section
|
-# Account Section
|
||||||
.mb-10
|
.mb-10
|
||||||
|
|
||||||
.step-one{"ng-if" => "!formData.showLogin && !formData.showRegister"}
|
.step-one{"ng-if" => "!formData.showLogin && !formData.showRegister && !formData.mfa"}
|
||||||
%h3 Sign in or register to enable sync and end-to-end encryption.
|
%h3 Sign in or register to enable sync and end-to-end encryption.
|
||||||
.small-v-space
|
.small-v-space
|
||||||
|
|
||||||
@@ -41,6 +41,11 @@
|
|||||||
Merge local data ({{notesAndTagsCount()}} notes and tags)
|
Merge local data ({{notesAndTagsCount()}} notes and tags)
|
||||||
%button.ui-button.block.mt-10{"ng-click" => "submitAuthForm()"} {{formData.showLogin ? "Sign In" : "Register"}}
|
%button.ui-button.block.mt-10{"ng-click" => "submitAuthForm()"} {{formData.showLogin ? "Sign In" : "Register"}}
|
||||||
|
|
||||||
|
%form.mt-5{"ng-if" => "formData.mfa"}
|
||||||
|
%p {{formData.mfa.message}}
|
||||||
|
%input.form-control.mt-10{:autofocus => 'autofocus', :name => 'mfa', :required => true, 'ng-model' => 'formData.userMfaCode'}
|
||||||
|
%button.ui-button.block.mt-10{"ng-click" => "submitMfaForm()"} {{"Sign In"}}
|
||||||
|
|
||||||
.mt-15{"ng-if" => "formData.showRegister"}
|
.mt-15{"ng-if" => "formData.showRegister"}
|
||||||
%h3 No Password Reset.
|
%h3 No Password Reset.
|
||||||
%p.mt-5 Because your notes are encrypted using your password, Standard Notes does not have a password reset option. You cannot forget your password.
|
%p.mt-5 Because your notes are encrypted using your password, Standard Notes does not have a password reset option. You cannot forget your password.
|
||||||
|
|||||||
Reference in New Issue
Block a user