2012-03-04 22:07:45 +00:00
|
|
|
class UsersController < ApplicationController
|
|
|
|
PER_PAGE = 20
|
|
|
|
|
|
|
|
def show
|
|
|
|
@user = User.find_by_nickname(params[:nickname])
|
2012-03-08 14:00:10 +00:00
|
|
|
@asciicasts = @user.asciicasts.
|
|
|
|
order("created_at DESC").
|
|
|
|
page(params[:page]).
|
|
|
|
per(PER_PAGE)
|
2012-03-04 22:07:45 +00:00
|
|
|
end
|
2012-03-05 23:25:21 +00:00
|
|
|
|
|
|
|
def create
|
|
|
|
@user = User.new(params[:user])
|
2012-03-10 13:58:10 +00:00
|
|
|
load_sensitive_user_data_from_session
|
2012-03-05 23:25:21 +00:00
|
|
|
if @user.save
|
2012-03-10 13:58:10 +00:00
|
|
|
clear_sensitive_session_user_data
|
2012-03-05 23:25:21 +00:00
|
|
|
self.current_user = @user
|
2012-03-06 22:04:35 +00:00
|
|
|
redirect_back_or_to root_url, :notice => "Signed in!"
|
2012-03-05 23:25:21 +00:00
|
|
|
else
|
|
|
|
render 'users/new', :status => 422
|
|
|
|
end
|
|
|
|
end
|
2012-03-10 13:58:10 +00:00
|
|
|
|
|
|
|
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
|
2012-03-04 22:07:45 +00:00
|
|
|
end
|