diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 31b960b73..e5e5f6b6f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -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 diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index cf892e07f..b3edd0a32 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -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 diff --git a/app/views/clients/index.html.erb b/app/views/clients/index.html.erb index debe69e50..b52d70c06 100644 --- a/app/views/clients/index.html.erb +++ b/app/views/clients/index.html.erb @@ -21,7 +21,7 @@
  • - {name} + {first_name} {last_name} {subtext}
  • @@ -30,7 +30,7 @@
    <%= gravatar_for current_user, size: 52, hclass: "avatar medium" %>
    -

    <%= current_user.name %>

    +

    <%= "#{current_user.first_name} #{current_user.last_name}" %>

    <%= image_tag "down_arrow.png", :class=> "profile-toggle" %>
    diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 69ba8413c..e57b20430 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -3,7 +3,7 @@
    - +
    @@ -11,8 +11,11 @@
    <%= 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 %>