Skip to content

Commit a31baa4

Browse files
committed
differentiate signup and login createdWith.action on _Session
1 parent 3603b82 commit a31baa4

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Diff for: spec/ParseUser.spec.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -1768,9 +1768,37 @@ describe('Parse.User testing', () => {
17681768
});
17691769
});
17701770

1771-
it('user get session from token', (done) => {
1771+
it('user get session from token on signup', (done) => {
17721772
Parse.Promise.as().then(() => {
17731773
return Parse.User.signUp("finn", "human", { foo: "bar" });
1774+
}).then((user) => {
1775+
request.get({
1776+
headers: {
1777+
'X-Parse-Application-Id': 'test',
1778+
'X-Parse-Session-Token': user.getSessionToken(),
1779+
'X-Parse-REST-API-Key': 'rest'
1780+
},
1781+
url: 'http://localhost:8378/1/sessions/me',
1782+
}, (error, response, body) => {
1783+
expect(error).toBe(null);
1784+
var b = JSON.parse(body);
1785+
expect(typeof b.sessionToken).toEqual('string');
1786+
expect(typeof b.createdWith).toEqual('object');
1787+
expect(b.createdWith.action).toEqual('signup');
1788+
expect(typeof b.user).toEqual('object');
1789+
expect(b.user.objectId).toEqual(user.id);
1790+
done();
1791+
});
1792+
});
1793+
});
1794+
1795+
it('user get session from token on login', (done) => {
1796+
Parse.Promise.as().then(() => {
1797+
return Parse.User.signUp("finn", "human", { foo: "bar" });
1798+
}).then((user) => {
1799+
return Parse.User.logOut().then(() => {
1800+
return Parse.User.logIn("finn", "human");
1801+
})
17741802
}).then((user) => {
17751803
request.get({
17761804
headers: {

Diff for: src/RestWrite.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ RestWrite.prototype.transformUser = function() {
327327
objectId: this.objectId()
328328
},
329329
createdWith: {
330-
'action': 'login',
330+
'action': 'signup',
331331
'authProvider': this.storage['authProvider'] || 'password'
332332
},
333333
restricted: false,

0 commit comments

Comments
 (0)