asciinema.org/app/controllers/users_controller.rb
Marcin Kulik 61b3890a3d Merge remote-tracking branch 'origin/unique-nickname'
* origin/unique-nickname:
  Keep sensitive signup data in session
  Add users factory back
  rm users factories
  Add view spec for users#new
  Add specs to user#create
  Validate nickname uniquness

Conflicts:
	Gemfile
	Gemfile.lock
2012-03-10 18:30:33 +01:00

36 lines
790 B
Ruby

class UsersController < ApplicationController
PER_PAGE = 20
def show
@user = User.find_by_nickname(params[:nickname])
@asciicasts = @user.asciicasts.
order("created_at DESC").
page(params[:page]).
per(PER_PAGE)
end
def create
@user = User.new(params[:user])
load_sensitive_user_data_from_session
if @user.save
clear_sensitive_session_user_data
self.current_user = @user
redirect_back_or_to root_url, :notice => "Signed in!"
else
render 'users/new', :status => 422
end
end
private
def load_sensitive_user_data_from_session
@user.provider = session[:provider]
@user.uid = session[:uid]
end
def clear_sensitive_session_user_data
session[:provider] = nil
session[:uid] = nil
end
end