File tree 3 files changed +24
-0
lines changed 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1010,6 +1010,24 @@ module.exports = function(AV) {
1010
1010
return user . logIn ( ) ;
1011
1011
} ,
1012
1012
1013
+ /**
1014
+ * Logs in a user with email and password.
1015
+ *
1016
+ * @since 3.13.0
1017
+ * @param {String } email The user's email.
1018
+ * @param {String } password The password to log in with.
1019
+ * @return {Promise } A promise that is fulfilled with the user when
1020
+ * the login completes.
1021
+ */
1022
+ loginWithEmail ( email , password ) {
1023
+ const user = AV . Object . _create ( '_User' ) ;
1024
+ user . _finishFetch ( {
1025
+ email,
1026
+ password,
1027
+ } ) ;
1028
+ return user . logIn ( ) ;
1029
+ } ,
1030
+
1013
1031
/**
1014
1032
* Sign up or logs in a user with a third party auth data(AccessToken).
1015
1033
* On success, this saves the session to disk, so you can retrieve the currently
Original file line number Diff line number Diff line change @@ -661,6 +661,7 @@ export class User extends Object {
661
661
mobilePhone : string ,
662
662
smsCode : string
663
663
) : Promise < User > ;
664
+ static loginWithEmail ( email : string , password : string ) : Promise < User > ;
664
665
static loginWithAuthData (
665
666
authData : object ,
666
667
platform : string ,
Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ describe('User', function() {
52
52
code : 210 ,
53
53
} ) ;
54
54
} ) ;
55
+
56
+ it ( 'should loginWithEmail' , ( ) =>
57
+ AV . User . loginWithEmail ( email , password ) . then ( function ( user ) {
58
+ expect ( user . get ( 'username' ) ) . to . be ( username ) ;
59
+ } ) ) ;
55
60
} ) ;
56
61
57
62
describe ( 'Current User' , function ( ) {
You can’t perform that action at this time.
0 commit comments