Skip to content

Commit 0db858b

Browse files
montymxbflovilmart
authored andcommitted
Enables login over POST in addition to GET (#4268)
* Enables login over POST in addition to GET * Removes explcit method:POST as rp.post does this naturally
1 parent d93b0e1 commit 0db858b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

spec/ParseUser.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,30 @@ describe('Parse.User testing', () => {
126126
});
127127
});
128128

129+
it('user login using POST with REST API', (done) => {
130+
Parse.User.signUp('some_user', 'some_password', null, {
131+
success: () => {
132+
return rp.post({
133+
url: 'http://localhost:8378/1/login',
134+
headers: {
135+
'X-Parse-Application-Id': Parse.applicationId,
136+
'X-Parse-REST-API-Key': 'rest',
137+
},
138+
json: {
139+
username: 'some_user',
140+
password: 'some_password',
141+
}
142+
}).then((res) => {
143+
expect(res.username).toBe('some_user');
144+
done();
145+
}).catch((err) => {
146+
fail(`no request should fail: ${JSON.stringify(err)}`);
147+
done();
148+
});
149+
},
150+
});
151+
});
152+
129153
it("user login", (done) => {
130154
Parse.User.signUp("asdf", "zxcv", null, {
131155
success: function() {

src/Routers/UsersRouter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ export class UsersRouter extends ClassesRouter {
256256
this.route('PUT', '/users/:objectId', req => { return this.handleUpdate(req); });
257257
this.route('DELETE', '/users/:objectId', req => { return this.handleDelete(req); });
258258
this.route('GET', '/login', req => { return this.handleLogIn(req); });
259+
this.route('POST', '/login', req => { return this.handleLogIn(req); });
259260
this.route('POST', '/logout', req => { return this.handleLogOut(req); });
260261
this.route('POST', '/requestPasswordReset', req => { return this.handleResetRequest(req); });
261262
this.route('POST', '/verificationEmailRequest', req => { return this.handleVerificationEmailRequest(req); });

0 commit comments

Comments
 (0)