Skip to content

Commit a55e4c8

Browse files
committed
wip: new trigger functions setup/login/update
1 parent 5b7bf4f commit a55e4c8

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

src/Adapters/Auth/AuthAdapter.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,69 @@ export class AuthAdapter {
3434
}
3535

3636
/**
37+
* Legacy usage, if provided it will be triggered when authData related to this provider is touched (signup/update/login)
38+
* otherwise you should implement validateSetup, validateLogin and validateUpdate
3739
@param authData: the client provided authData
3840
@param options: additional options
3941
@param req: RestWrite instance with config/auth/data
42+
@param user: Parse.User instance if Parse.User found
4043
@returns a promise that resolves, the resolved value will be handled by the server like:
4144
- resolve undefined|void|{} parse server will save authData
4245
- resolve { doNotSave: boolean, response: Object} parse server will do not save provided authData and send response to the client under authDataResponse
4346
- resolve { response: Object } parse server will save authData and send response to the client under authDataResponse
4447
- resolve { response: Object, save: Object } parse server will save the object provided into `save` key and send response to the client under authDataResponse
4548
*/
46-
validateAuthData(authData, options, req) {
49+
validateAuthData(authData, options, req, user) {
50+
return Promise.resolve({});
51+
}
52+
53+
/**
54+
* Triggered when user provide for the first time this auth provider
55+
@param authData: the client provided authData
56+
@param options: additional options
57+
@param req: RestWrite instance with config/auth/data
58+
@param user: Parse.User instance if Parse.User found
59+
@returns a promise that resolves, the resolved value will be handled by the server like:
60+
- resolve undefined|void|{} parse server will save authData
61+
- resolve { doNotSave: boolean, response: Object} parse server will do not save provided authData and send response to the client under authDataResponse
62+
- resolve { response: Object } parse server will save authData and send response to the client under authDataResponse
63+
- resolve { response: Object, save: Object } parse server will save the object provided into `save` key and send response to the client under authDataResponse
64+
*/
65+
validateSetUp(authData, options, req, user) {
66+
return Promise.resolve({});
67+
}
68+
69+
/**
70+
* Triggered when user provide authData related to this provider
71+
* he is not logged in and has already set this provider before
72+
@param authData: the client provided authData
73+
@param options: additional options
74+
@param req: RestWrite instance with config/auth/data
75+
@param user: Parse.User instance if Parse.User found
76+
@returns a promise that resolves, the resolved value will be handled by the server like:
77+
- resolve undefined|void|{} parse server will save authData
78+
- resolve { doNotSave: boolean, response: Object} parse server will do not save provided authData and send response to the client under authDataResponse
79+
- resolve { response: Object } parse server will save authData and send response to the client under authDataResponse
80+
- resolve { response: Object, save: Object } parse server will save the object provided into `save` key and send response to the client under authDataResponse
81+
*/
82+
validateLogin(authData, options, req, user) {
83+
return Promise.resolve({});
84+
}
85+
86+
/**
87+
* Triggered when user provide authData related to this provider
88+
* he is logged in and has already set this provider before
89+
@param authData: the client provided authData
90+
@param options: additional options
91+
@param req: RestWrite instance with config/auth/data
92+
@param user: Parse.User instance if Parse.User found
93+
@returns a promise that resolves, the resolved value will be handled by the server like:
94+
- resolve undefined|void|{} parse server will save authData
95+
- resolve { doNotSave: boolean, response: Object} parse server will do not save provided authData and send response to the client under authDataResponse
96+
- resolve { response: Object } parse server will save authData and send response to the client under authDataResponse
97+
- resolve { response: Object, save: Object } parse server will save the object provided into `save` key and send response to the client under authDataResponse
98+
*/
99+
validateUpdate(authData, options, req, user) {
47100
return Promise.resolve({});
48101
}
49102

0 commit comments

Comments
 (0)