Skip to content

Commit

Permalink
differentiate signup and login createdWith.action on _Session
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed Mar 20, 2016
1 parent 3603b82 commit a31baa4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 29 additions & 1 deletion spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1768,9 +1768,37 @@ describe('Parse.User testing', () => {
});
});

it('user get session from token', (done) => {
it('user get session from token on signup', (done) => {
Parse.Promise.as().then(() => {
return Parse.User.signUp("finn", "human", { foo: "bar" });
}).then((user) => {
request.get({
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Session-Token': user.getSessionToken(),
'X-Parse-REST-API-Key': 'rest'
},
url: 'http://localhost:8378/1/sessions/me',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
expect(typeof b.sessionToken).toEqual('string');
expect(typeof b.createdWith).toEqual('object');
expect(b.createdWith.action).toEqual('signup');
expect(typeof b.user).toEqual('object');
expect(b.user.objectId).toEqual(user.id);
done();
});
});
});

it('user get session from token on login', (done) => {
Parse.Promise.as().then(() => {
return Parse.User.signUp("finn", "human", { foo: "bar" });
}).then((user) => {
return Parse.User.logOut().then(() => {
return Parse.User.logIn("finn", "human");
})
}).then((user) => {
request.get({
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ RestWrite.prototype.transformUser = function() {
objectId: this.objectId()
},
createdWith: {
'action': 'login',
'action': 'signup',
'authProvider': this.storage['authProvider'] || 'password'
},
restricted: false,
Expand Down

0 comments on commit a31baa4

Please sign in to comment.