Answer the question
In order to leave comments, you need to log in
How to make authentication through classmates in Angularjs?
I need to implement authentication through the social network classmates on my project using Angularjs. Does anyone know what tools to use for this purpose? So far I have not found anything suitable on the Internet. Thanks in advance.
Answer the question
In order to leave comments, you need to log in
We did it on Ember.js, but the meaning is the same - you can not use the framework at all.
https://github.com/incubus/omniauth-odnoklassniki - we set ourselves a gem for authentication.
By clicking on the button, we open a new window with the authentication address Code
example on Ember.js but the meaning should be clear
SomeApp.SocialLoginButtonView = Ember.View.extend(
tagName: "a"
attributeBindings: ['href']
click: (e)->
e.preventDefault()
provider = $(e.currentTarget).attr('href')
url = "/users/auth/#{provider}?transition_to_root=true"
window.open(
url, '_blank',
'width=600,height=500,location=yes,resizable=yes,scrollbars=yes'
)
)
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
layout 'blank'
def facebook
sign_in_with_oauth_data(request.env['omniauth.auth'])
end
def twitter
sign_in_with_oauth_data(request.env['omniauth.auth'])
end
private
def sign_in_with_oauth_data(oauth_data)
unless user_signed_in?
user = User.find_or_create_with_oauth(oauth_data)
sign_in :user, user
MailWorker.perform_in(1.hour, user.id, :account_dropoff)
end
@success = current_user.register_social_profile(normalize_oauth_data(oauth_data))
@service_name = oauth_data.provider
render 'shared/social_authentication'
end
def normalize_oauth_data(oauth_data)
{ service_name: oauth_data.provider, uid: oauth_data.uid, access_token: oauth_data.credentials.token, secret_key: oauth_data.credentials.secret }
end
end
<script type="text/javascript" charset="UTF-8">
<% if @success %>
window.opener.SomeApp.sendSuccess()
<% else %>
window.opener.SomeApp.sendFailure()
<% end %>
window.close();
</script>
Take any oauth2 for angular and write an implementation for OK.
Or look towards rails omniauth odnoklassniki.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question