Skip to content

Commit

Permalink
Merge pull request #815 from oceanzus/redesign_loginfixes
Browse files Browse the repository at this point in the history
Adds check for valid user email for password reset.
  • Loading branch information
oceanzus authored Feb 17, 2017
2 parents 8dd07ac + 90599d9 commit feb1d81
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ooiui/core/routes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ def submit_user():
response = requests.post(app.config['SERVICES_URL'] + '/user', headers={'X-Csrf-Token' : api_key}, data=request.data)
return response.text, response.status_code


@app.route('/api/user/check_valid_email', methods=['GET'])
def check_valid_email():
response = requests.get(app.config['SERVICES_URL'] + '/user/check_valid_email', params=request.args)
return response.text, response.status_code


@app.route('/api/user_scope', methods=['GET'])
def get_user_scopes():
token = get_login()
Expand Down
21 changes: 21 additions & 0 deletions ooiui/static/js/models/common/LoginModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ var LoginModel = Backbone.Model.extend({
// var self = this;
// return true;
//},
checkValidEmail: function(email) {
var output = false;
$.ajax('/api/user/check_valid_email?email='+email, {
type: 'GET',
dataType: 'json',
timeout: 5000,
async: false,
success: function (resp) {
// console.log('Success getting check valid email');
// console.log(resp);
if(resp.email !== undefined && resp.email !== ""){
output = true
}
},

error: function( req, status, err ) {
console.log(req);
}
});
return output;
},
loggedIn: function() {
if(this.get('token') != '') {
return true;
Expand Down
8 changes: 4 additions & 4 deletions ooiui/static/js/views/common/LoginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var LoginView = Backbone.View.extend({
sendResetEmail: function(e) {
//console.log('hit reset inside LoginView.js');
var emailAddr = this.$el.find('#usrInput').val();
if(emailAddr != null && emailAddr != ""){
if(emailAddr != null && emailAddr != "" && this.model.checkValidEmail(emailAddr)){
var userEmail = {email: this.$el.find('#usrInput').val()};
//console.log(userEmail);
$.ajax( '/password-reset-request', {
Expand All @@ -75,7 +75,7 @@ var LoginView = Backbone.View.extend({
var m = new ModalDialogView();

m.show({
message: "Sent password reset email successfully.",
message: "Please check your inbox for a password reset link.",
type: "success"
});

Expand All @@ -99,8 +99,8 @@ var LoginView = Backbone.View.extend({
} else {
var errorEmailModal = new ModalDialogView();
errorEmailModal.show({
message: "Please enter an email address above.",
type: "danger"
message: "Please check your inbox for a password reset link.",
type: "success"
});
}

Expand Down

0 comments on commit feb1d81

Please sign in to comment.