Skip to content

Commit a76b174

Browse files
committed
Merge branch 'master' of github.com:topcoderinc/dsp-app
2 parents 7a2728c + 9586daa commit a76b174

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/api/User.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ class UserApi {
4444
password: password,
4545
})});
4646
}
47+
48+
registerSocialUser(name, email) {
49+
const url = `${this.basePath}/api/v1/users/social`;
50+
51+
return reqwest({ url: url, method: 'post', type: 'json',
52+
contentType: 'application/json',
53+
data: JSON.stringify({
54+
name: name,
55+
email: email,
56+
})});
57+
}
4758
}
4859

4960
export default UserApi;

src/components/auth/utils/AuthService.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
*/
1111

1212
import Auth0Lock from 'auth0-lock'
13+
import config from '../../../config';
14+
import UserApi from '../../../api/User.js';
15+
16+
const userApi = new UserApi(config.api.basePath);
1317

1418
export default class AuthService {
1519

@@ -28,6 +32,18 @@ export default class AuthService {
2832
_doAuthentication(authResult, a, b, c) {
2933
// Saves the user token
3034
this.setToken(authResult.idToken);
35+
var that = this;
36+
this.lock.getProfile(authResult.idToken, function(error, profile) {
37+
if (error) {
38+
console.log(error);
39+
return;
40+
}
41+
userApi.registerSocialUser(profile.name, profile.email).then((authResult) => {
42+
that.setToken(authResult.accessToken);
43+
}).catch((err) => {
44+
console.error(err);
45+
});
46+
});
3147
}
3248

3349
login() {

0 commit comments

Comments
 (0)