now oauth is working
This commit is contained in:
parent
b4f0d3b9eb
commit
96c16eb1e5
|
|
@ -4,8 +4,6 @@ class SessionsController < ApplicationController
|
|||
def new
|
||||
end
|
||||
|
||||
# oauth information:
|
||||
# http://net.tutsplus.com/tutorials/ruby/how-to-use-omniauth-to-authenticate-your-users/
|
||||
|
||||
def create
|
||||
user = User.authenticate(params[:session][:email], params[:session][:password])
|
||||
|
|
@ -18,6 +16,8 @@ class SessionsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# OAuth docs
|
||||
# http://net.tutsplus.com/tutorials/ruby/how-to-use-omniauth-to-authenticate-your-users/
|
||||
def create_oauth
|
||||
auth_hash = request.env['omniauth.auth']
|
||||
authorization = UserAuthorization.find_by_provider_and_uid(auth_hash["provider"], auth_hash["uid"])
|
||||
|
|
@ -49,9 +49,10 @@ class SessionsController < ApplicationController
|
|||
nil, # @country
|
||||
nil,
|
||||
nil)
|
||||
user.user_authorizations.build :provider => auth_hash[:provider], :uid => auth_hash[:uid],
|
||||
:token => auth_hash[:credentials][:token], :token_expiration => auth_hash[:credentials][:expires_at]
|
||||
auth = user.user_authorizations.build :provider => auth_hash[:provider], :uid => auth_hash[:uid],
|
||||
:token => auth_hash[:credentials][:token], :token_expiration => Time.at(auth_hash[:credentials][:expires_at])
|
||||
user.save
|
||||
auth.save
|
||||
complete_sign_in user
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ module UsersHelper
|
|||
hclass = options[:hclass]
|
||||
gravatar =
|
||||
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
|
||||
image_tag(gravatar_url, alt: user.name, class: "#{hclass}")
|
||||
image_tag(gravatar_url, alt: "#{user.first_name} #{user.last_name}", class: "#{hclass}")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<li>
|
||||
<a>
|
||||
<img src="{image}"/>
|
||||
<span class="text">{name}</span>
|
||||
<span class="text">{first_name} {last_name}</span>
|
||||
<span class="subtext">{subtext}</span>
|
||||
</a>
|
||||
</li>
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
<div class="userinfo">
|
||||
<%= gravatar_for current_user, size: 52, hclass: "avatar medium" %>
|
||||
<div class="username">
|
||||
<h2><%= current_user.name %></h2>
|
||||
<h2><%= "#{current_user.first_name} #{current_user.last_name}" %></h2>
|
||||
<%= image_tag "down_arrow.png", :class=> "profile-toggle" %>
|
||||
<ul>
|
||||
<li><a layout-link="account">Profile</a></li>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
<% provide(:title, "Sign in") %>
|
||||
<h1>Sign in</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="span6 offset3">
|
||||
<a href="/auth/facebook"><img src="/fb-signup-button.png"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span6 offset3">
|
||||
<%= form_for(:session, url: sessions_path) do |f| %>
|
||||
|
|
@ -16,4 +22,4 @@
|
|||
|
||||
<p>New user? <%= link_to "Sign up now!", signup_path %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="span6 offset3">
|
||||
<a href="/auth/facebook"><img src="http://ventnation.com/images/fb-signup-button.png?1343414918"></a>
|
||||
<a href="/auth/facebook"><img src="/fb-signup-button.png"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -11,8 +11,11 @@
|
|||
<div class="span6 offset3">
|
||||
<%= form_for(@user) do |f| %>
|
||||
<%= render 'shared/error_messages', object: f.object %>
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name %>
|
||||
<%= f.label :first_name %>
|
||||
<%= f.text_field :first_name %>
|
||||
|
||||
<%= f.label :last_name %>
|
||||
<%= f.text_field :last_name %>
|
||||
|
||||
<%= f.label :email %>
|
||||
<%= f.text_field :email %>
|
||||
|
|
|
|||
Loading…
Reference in New Issue