Skip to content

Commit

Permalink
Ensure only necessary fields are used for auth, text updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thostetler committed Jun 4, 2024
1 parent bccea84 commit db71e05
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 40 deletions.
24 changes: 20 additions & 4 deletions src/js/components/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ define([
},
});

const payloads = {
login: ['email', 'password'],
register: [
'given_name',
'family_name',
'email',
'password1',
'password2',
'g-recaptcha-response',
],
resetPassword1: ['g-recaptcha-response'],
resetPassword2: ['password1', 'password2'],
};

const getPayload = (data, type) => JSON.stringify(_.pick(data, payloads[type]));

var Session = GenericModule.extend({
initialize: function(options) {
var options = options || {};
Expand Down Expand Up @@ -69,7 +85,7 @@ define([
query: new ApiQuery({}),
options: {
type: 'POST',
data: JSON.stringify(_.pick(data, 'email', 'password')),
data: getPayload(data, 'login'),
contentType: 'application/json',
headers: { 'X-CSRFToken': csrfToken },
done: function() {
Expand Down Expand Up @@ -133,7 +149,7 @@ define([
query: new ApiQuery({}),
options: {
type: 'POST',
data: JSON.stringify(_.pick(data, 'given_name', 'family_name', 'email', 'password1', 'password2', 'g-recaptcha-response')),
data: getPayload(data, 'register'),
contentType: 'application/json',
headers: { 'X-CSRFToken': csrfToken },
done: this.registerSuccess,
Expand All @@ -156,7 +172,7 @@ define([
query: new ApiQuery({}),
options: {
type: 'POST',
data: JSON.stringify(data),
data: getPayload(data, 'resetPassword1'),
headers: { 'X-CSRFToken': csrfToken },
contentType: 'application/json',
done: this.resetPassword1Success,
Expand All @@ -179,7 +195,7 @@ define([
query: new ApiQuery({}),
options: {
type: 'PUT',
data: JSON.stringify(data),
data: getPayload(data, 'resetPassword2'),
contentType: 'application/json',
headers: { 'X-CSRFToken': csrfToken },
done: this.resetPassword2Success,
Expand Down
10 changes: 5 additions & 5 deletions src/js/widgets/authentication/templates/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
First Name
</label>
<span class="help-block no-show s-help-block"></span>
<input type="text" class="form-control" name="given_name" id="given_name" placeholder="Arthur"/>
<input type="text" class="form-control" name="given_name" id="given_name" placeholder="First Name"/>
</div>

<div class="form-group has-feedback">
<label for="family_name" class="control-label">
Last Name
</label>
<span class="help-block no-show s-help-block"></span>
<input type="text" class="form-control" name="family_name" id="family_name" placeholder="Dent"/>
<input type="text" class="form-control" name="family_name" id="family_name" placeholder="Last Name"/>
</div>

<div class="form-group has-feedback">
Expand All @@ -31,10 +31,10 @@
<label for="password1" class="control-label">
Password
<span style="color:red">*</span>
<small class="s-user-help"> at least 5 characters, with at least 1 number and 1 letter</small>
<small class="s-user-help"> at least 8 characters, with at least 1 number and 1 capital letter</small>
</label>
<span class="help-block no-show s-help-block"></span>
<input type="password" class="form-control" name="password1" id="password1" placeholder="*******"/>
<input type="password" class="form-control" name="password1" id="password1" placeholder="********"/>
</div>

<div class="form-group has-feedback">
Expand All @@ -43,7 +43,7 @@
<span style="color:red">*</span>
</label>
<span class="help-block no-show s-help-block"></span>
<input type="password" class="form-control" name="password2" id="password2" placeholder="*******"/>
<input type="password" class="form-control" name="password2" id="password2" placeholder="********"/>
</div>

<div class="form-group">
Expand Down
4 changes: 2 additions & 2 deletions src/js/widgets/authentication/templates/reset-password-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="form-group has-feedback">
<label for="password1" class="control-label"> New password </label>
<span class="help-block no-show s-help-block"></span>
<div class="s-user-help">Passwords should be at least five characters and include at least one number and one letter.</div>
<div class="s-user-help">Passwords should be at least eight characters and include at least one number and one capital letter.</div>
<input type="password" class="form-control" name="password1" id="password1" placeholder="Password"/>

</div>
Expand Down Expand Up @@ -33,4 +33,4 @@
</div>
</div>
{{/if}}
</div>
</div>
55 changes: 26 additions & 29 deletions src/js/widgets/user_settings/templates/change_password.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
<div class="panel panel-default s-form-container">
<legend class="panel-heading"> Change Your Password
</legend>
<form class="panel-body">
<div class="form-group has-feedback">
<label for="old_password" class="control-label"> Current password </label>
<span class="help-block no-show s-help-block"></span>
<input type="password" class="form-control" name="old_password" id="old_password">
</div>
<div class="form-group has-feedback">
<label for="new_password1" class="control-label"> New password </label>
<span class="help-block no-show s-help-block"></span>
<div class="s-user-help">Passwords should be at least five characters and include at least one number and one letter.</div>
<input type="password" class="form-control" name="new_password1" id="new_password1" >

</div>
<div class="form-group has-feedback">
<label for="new_password2" class="control-label"> Retype new password </label>
<span class="help-block no-show s-help-block"></span>
<input type="password" class="form-control" name="new_password2" id="new_password2">

</div>


<div class="form-group">
<button type="submit" class="btn btn-primary-faded">Submit</button>
<span class="help-block no-show s-help-block"></span>
</div>
</form>
</div>
<legend class="panel-heading"> Change Your Password</legend>
<form class="panel-body">
<div class="form-group has-feedback">
<label for="old_password" class="control-label"> Current password </label>
<span class="help-block no-show s-help-block"></span>
<input type="password" class="form-control" name="old_password" id="old_password">
</div>
<div class="form-group has-feedback">
<label for="new_password1" class="control-label"> New password </label>
<span class="help-block no-show s-help-block"></span>
<div class="s-user-help">Passwords should be at least eight characters and include at least one number and one
capital letter.
</div>
<input type="password" class="form-control" name="new_password1" id="new_password1">
</div>
<div class="form-group has-feedback">
<label for="new_password2" class="control-label"> Retype new password </label>
<span class="help-block no-show s-help-block"></span>
<input type="password" class="form-control" name="new_password2" id="new_password2">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary-faded">Submit</button>
<span class="help-block no-show s-help-block"></span>
</div>
</form>
</div>

0 comments on commit db71e05

Please sign in to comment.