61b3890a3d
* 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
36 lines
790 B
Ruby
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
|