This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The frontend includes two routes, which are the passwordreset and passwordresetcomplete. Password reset is linked to the login page with the text "Forgot your password?".
- Loading branch information
Showing
10 changed files
with
227 additions
and
11 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
15 changes: 15 additions & 0 deletions
15
src-backbone/app/js/templates/auth/resetPasswordCompleteView.hbs
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,15 @@ | ||
<form> | ||
<div class="form-group"> | ||
<label for="new_password" class="sr-only">{{ i18n "New Password" }}</label> | ||
<input type="password" name="new_password" class="form-control" id="new_password" placeholder="New Password"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="password_confirmation" class="sr-only">{{ i18n "Confirm Password" }}</label> | ||
<input type="password" name="password_confirmation" class="form-control" id="password_confirmation" placeholder="Confirm Password"> | ||
</div> | ||
|
||
<div> | ||
<button type="submit" class="btn btn-primary btn-block" id="submit-btn">{{ i18n "Change Password" }}</button> | ||
</div> | ||
</form> |
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,10 @@ | ||
<form> | ||
<div class="form-group"> | ||
<label for="email" class="sr-only">{{ i18n "Email" }}</label> | ||
<input type="text" name="email" class="form-control" id="email" placeholder="Email"> | ||
</div> | ||
|
||
<div> | ||
<button type="submit" class="btn btn-primary btn-block" id="submit-btn">{{ i18n "Request Password Reset" }}</button> | ||
</div> | ||
</form> |
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
65 changes: 65 additions & 0 deletions
65
src-backbone/app/js/views/auth/resetPasswordCompleteView.js
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,65 @@ | ||
let App = require('utils/sanaAppInstance'); | ||
const Helpers = require('utils/helpers'); | ||
|
||
module.exports = Marionette.ItemView.extend({ | ||
template: require('templates/auth/resetPasswordCompleteView'), | ||
|
||
ui: { | ||
form: 'form', | ||
}, | ||
|
||
events: { | ||
'submit': 'onSubmit', | ||
}, | ||
|
||
onSubmit: function(event) { | ||
event.preventDefault(); | ||
|
||
let self = this; | ||
let $form = this.ui.form; | ||
|
||
self.completeReset($form.serializeArray()); | ||
}, | ||
|
||
completeReset: function(data) { | ||
let token = Helpers.getURLParam(Backbone.history.fragment, 'reset_token'); | ||
let json = {}; | ||
data.forEach(function(item) { | ||
if (item.value !== "") { | ||
json[item.name] = item.value; | ||
} | ||
}); | ||
json.reset_token = token; | ||
|
||
$.ajax({ | ||
type: 'POST', | ||
url: '/api/passwords/reset_password_complete', | ||
data: JSON.stringify(json), | ||
beforeSend: function() { | ||
App().RootView.showSpinner(); | ||
}, | ||
complete: function() { | ||
App().RootView.hideSpinner(); | ||
}, | ||
success: function(response) { | ||
Helpers.navigateToDefaultLoggedOut(); | ||
App().RootView.clearNotifications(); | ||
App().RootView.showNotification({ | ||
title: 'Success!', | ||
desc: 'Password successfully reset!', | ||
alertType: 'success', | ||
}); | ||
}, | ||
error: function(errors) { | ||
App().RootView.clearNotifications(); | ||
Object.keys(errors.responseJSON).forEach(function(key) { | ||
App().RootView.showNotification({ | ||
title: 'There was a problem', | ||
desc: errors.responseJSON[key] | ||
}); | ||
}); | ||
} | ||
}); | ||
}, | ||
|
||
}); |
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,63 @@ | ||
let App = require('utils/sanaAppInstance'); | ||
const Helpers = require('utils/helpers'); | ||
|
||
module.exports = Marionette.ItemView.extend({ | ||
template: require('templates/auth/resetPasswordView'), | ||
|
||
ui: { | ||
form: 'form', | ||
}, | ||
|
||
events: { | ||
'submit': 'onSubmit', | ||
}, | ||
|
||
onSubmit: function(event) { | ||
event.preventDefault(); | ||
|
||
let self = this; | ||
let $form = this.ui.form; | ||
|
||
self.resetPassword($form.serializeArray()); | ||
}, | ||
|
||
resetPassword: function(data) { | ||
let json = {}; | ||
data.forEach(function(item) { | ||
if (item.value !== "") { | ||
json[item.name] = item.value; | ||
} | ||
}); | ||
|
||
$.ajax({ | ||
type: 'POST', | ||
data: JSON.stringify(json), | ||
url: '/api/passwords/reset_password', | ||
beforeSend: function() { | ||
App().RootView.showSpinner(); | ||
}, | ||
complete: function() { | ||
App().RootView.hideSpinner(); | ||
}, | ||
success: function(response) { | ||
Helpers.navigateToDefaultLoggedOut(); | ||
App().RootView.clearNotifications(); | ||
App().RootView.showNotification({ | ||
title: 'Success!', | ||
desc: 'Email to reset password sent!', | ||
alertType: 'success', | ||
}); | ||
}, | ||
error: function(errors) { | ||
App().RootView.clearNotifications(); | ||
Object.keys(errors.responseJSON).forEach(function(key) { | ||
App().RootView.showNotification({ | ||
title: 'There was a problem', | ||
desc: errors.responseJSON[key] | ||
}); | ||
}); | ||
} | ||
}); | ||
}, | ||
|
||
}); |
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