Skip to content

Commit

Permalink
Merge 66a49af into 419c2ab
Browse files Browse the repository at this point in the history
  • Loading branch information
thostetler committed Mar 28, 2024
2 parents 419c2ab + 66a49af commit 0dde483
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/js/apps/discovery/navigator.js
Expand Up @@ -1031,7 +1031,7 @@ define([
.execute()
.then(function() {
var msg =
'<p>You have been successfully registered with the username</p> <p><b>' +
'<p>You have been successfully registered with the email</p> <p><b>' +
reply.email +
'</b></p>';
self.getPubSub().publish(
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/session.js
Expand Up @@ -69,7 +69,7 @@ define([
query: new ApiQuery({}),
options: {
type: 'POST',
data: JSON.stringify(data),
data: JSON.stringify(_.pick(data, 'email', 'password')),
contentType: 'application/json',
headers: { 'X-CSRFToken': csrfToken },
done: function() {
Expand Down
6 changes: 3 additions & 3 deletions src/js/components/user.js
Expand Up @@ -385,8 +385,8 @@ define([
},

/* set user */
setUser: function(username) {
this.userModel.set('user', username);
setUser: function(email) {
this.userModel.set('user', email);
if (this.isLoggedIn()) {
this.completeLogIn();
}
Expand Down Expand Up @@ -538,7 +538,7 @@ define([
},

hardenedInterface: {
setUser: 'set username into user',
setUser: 'set email into user',
isLoggedIn: 'whether the user is logged in',
getUserName: "get the user's email before the @",
setLocalStorage: "sets an object in to user's local storage",
Expand Down
2 changes: 1 addition & 1 deletion src/js/mixins/api_access.js
Expand Up @@ -28,7 +28,7 @@ define([
console.warn('Redefining access_token: ' + data.access_token);

var userObject = beehive.getObject('User');
var userName = data.anonymous ? undefined : data.username;
var userName = data.anonymous ? undefined : data.email;
userObject.setUser(userName);
var storage = beehive.getService('PersistentStorage');
storage && storage.set && storage.set('appConfig', data);
Expand Down
4 changes: 2 additions & 2 deletions src/js/widgets/authentication/templates/log-in.html
Expand Up @@ -4,9 +4,9 @@
</legend>
<form class="panel-body">
<div class="form-group has-feedback">
<label for="username" class="control-label"> Email address </label>
<label for="email" class="control-label"> Email address </label>
<span class="help-block no-show s-help-block"></span>
<input type="email" class="form-control" name="username" id="username" placeholder="Enter email" />
<input type="email" class="form-control" name="email" id="email" placeholder="Enter email" />
</div>

<div class="form-group has-feedback">
Expand Down
8 changes: 4 additions & 4 deletions src/js/widgets/authentication/widget.js
Expand Up @@ -169,9 +169,9 @@ define([
var LogInModel;

LogInModel = FormModel.extend({
skipReset: ['username'],
skipReset: ['email'],
validation: {
username: {
email: {
required: true,
pattern: 'email',
msg: '(A valid email is required)',
Expand All @@ -192,8 +192,8 @@ define([
className: 'log-in s-log-in',

bindings: {
'input[name=username]': {
observe: 'username',
'input[name=email]': {
observe: 'email',
setOptions: {
validate: true,
},
Expand Down
2 changes: 1 addition & 1 deletion test/mocha/js/apps/discovery/navigator.spec.js
Expand Up @@ -298,7 +298,7 @@ define([
expect(p.state()).to.eql('resolved');
expect(fakePubSub.publish.args[0][2].toJSON()).to.eql({
"code": 0,
"msg": "<p>You have been successfully registered with the username</p> <p><b>foo</b></p>"
"msg": "<p>You have been successfully registered with the email</p> <p><b>foo</b></p>"
})


Expand Down
4 changes: 2 additions & 2 deletions test/mocha/js/components/application.spec.js
Expand Up @@ -180,7 +180,7 @@ define([
expect(apiRequest.url()).to.contain('/accounts/bootstrap');
options.done(
{
"username": "user@gmail.com",
"email": "user@gmail.com",
"scopes": ["user"],
"access_token": "ap0MkGjroS1zzijLlk9fV2UKXdRDo5nzUueTNaog",
"token_type": "Bearer",
Expand All @@ -198,7 +198,7 @@ define([
.done(function () {
expect(spy.called).to.eql(true);
expect(api.access_token).to.eql('Bearer ap0MkGjroS1zzijLlk9fV2UKXdRDo5nzUueTNaog');
//every time onbootstrap is called, update the user object with username/undefined to show that user is anonymous
//every time onbootstrap is called, update the user object with email/undefined to show that user is anonymous
expect(fakeUser.setUser.args[0]).to.eql(["user@gmail.com"]);
done();
})
Expand Down
17 changes: 8 additions & 9 deletions test/mocha/js/components/session.spec.js
Expand Up @@ -29,7 +29,7 @@ define([
it('has an explicit method for every action (login, logout, register, etc) a user might need to do before he/she is authenticated', function() {
var s = new Session({ test: true });
var minsub = new (MinSub.extend({
request: function(apiRequest) {},
request: function(apiRequest) { },
}))({ verbose: false });

var api = new Api();
Expand All @@ -49,9 +49,8 @@ define([
s.activate(minsub.beehive);

s.login({
username: 'goo',
email: 'goo',
password: 'foo',
'g-recaptcha-response': 'boo',
});

csrfManager.resolvePromiseWithNewKey();
Expand All @@ -60,7 +59,7 @@ define([
expect(requestStub.args[0][0].toJSON().target).to.eql('accounts/user/login');
expect(requestStub.args[0][0].toJSON().options.type).to.eql('POST');
expect(requestStub.args[0][0].toJSON().options.data).to.eql(
'{"username":"goo","password":"foo","g-recaptcha-response":"boo"}'
'{"email":"goo","password":"foo"}'
);

s.logout();
Expand Down Expand Up @@ -108,7 +107,7 @@ define([
s.registerFail
);

const resetPasswordPayload = {email: 'goo@goo.com', 'g-recaptcha-response': 'boo'}
const resetPasswordPayload = { email: 'goo@goo.com', 'g-recaptcha-response': 'boo' }
s.resetPassword1(resetPasswordPayload);

csrfManager.resolvePromiseWithNewKey();
Expand All @@ -120,8 +119,8 @@ define([
expect(requestStub.args[3][0].toJSON().options.type).to.eql('POST');
expect(
requestStub.args[3][0].toJSON().options.data).to.eql(
'{"g-recaptcha-response":"boo"}',
);
'{"g-recaptcha-response":"boo"}',
);
expect(requestStub.args[3][0].toJSON().options.done).to.eql(
s.resetPassword1Success
);
Expand Down Expand Up @@ -157,7 +156,7 @@ define([

it('handles fail of method by 1) sending pubsub method and 2) sending alert', function() {
var minsub = new (MinSub.extend({
request: function(apiRequest) {},
request: function(apiRequest) { },
}))({ verbose: false });

var s = new Session();
Expand Down Expand Up @@ -213,7 +212,7 @@ define([

it('handles success of methods by 1) sending pubsub method and 2) optionally doing additional work', function() {
var minsub = new (MinSub.extend({
request: function(apiRequest) {},
request: function(apiRequest) { },
}))({ verbose: false });

var s = new Session();
Expand Down
2 changes: 1 addition & 1 deletion test/mocha/js/widgets/navbar_widget.spec.js
Expand Up @@ -209,7 +209,7 @@ define([
.replace(/\W+/g, ' ')
).to.eql('You are signed in as bumblebee');

// lack of username indicates user is logged out
// lack of email indicates user is logged out
u.setUser(undefined);

minsub.publish(
Expand Down

0 comments on commit 0dde483

Please sign in to comment.