Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var _registerExternal = function (registerExternalData) {
- var deferred = $q.defer();
- FB.api('/me', { fields: 'first_name,last_name,email' }, function (resp) {
- var data = {
- provider: 'Facebook',
- externalAccessToken: registerExternalData.externalAccessToken,
- email: resp.email,
- firstName: resp.first_name,
- lastName: resp.last_name
- };
- $http.post(serviceBase + 'auth/register/external', data).success(function (response) {
- localStorageService.set('authorizationData', { token: response.access_token, userName: response.userName, userId: response.user_id, roles: response.roles + ',User', refreshToken: "", useRefreshTokens: false });
- _authentication.isAuth = true;
- _authentication.userName = response.userName;
- _authentication.userId = response.user_id;
- _authentication.roles = response.roles + ',User';
- _authentication.useRefreshTokens = true;
- deferred.resolve(response);
- }).error(function (err, status) {
- _logOut();
- deferred.reject(err);
- });
- });
- return deferred.promise;
- };
- //i po-nadolu e tova:
- FB.Event.subscribe('auth.authResponseChange', function (res) {
- if (res.status === 'connected') {
- /*
- The user is already logged,
- is possible retrieve his personal info
- */
- _obtainAccessToken({ provider: 'Facebook', externalAccessToken: res.authResponse.accessToken });
- /*
- This is also the point where you should create a
- session for the current user.
- For this purpose you can use the data inside the
- res.authResponse object.
- */
- }
- else {
- /*
- The user is not logged to the app, or into Facebook:
- destroy the session on the server.
- */
- }
- });
- FB.Event.subscribe('auth.statusChange', function (res) {
- console.log("respn");
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement