Module: DoubleAuthEngine::UsersControllerMixin::InstanceMethods
- Defined in:
- lib/double_auth_engine/controllers/users_controller_mixin.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_password ⇒ Object
Instance Method Details
#create ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/double_auth_engine/controllers/users_controller_mixin.rb', line 30 def create @user = User.new(params[:user]) if @user.save flash[:notice] = 'User successfully created' respond_with(@user) else render :action => 'new', :layout => false end end |
#destroy ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/double_auth_engine/controllers/users_controller_mixin.rb', line 55 def destroy @user = User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to(users_url) } format.xml { head :ok } end end |
#edit ⇒ Object
40 41 42 43 |
# File 'lib/double_auth_engine/controllers/users_controller_mixin.rb', line 40 def edit @user = User.find(params[:id]) respond_with(@user) end |
#index ⇒ Object
13 14 15 16 |
# File 'lib/double_auth_engine/controllers/users_controller_mixin.rb', line 13 def index @users = User.all respond_with(@users) end |
#new ⇒ Object
23 24 25 26 27 28 |
# File 'lib/double_auth_engine/controllers/users_controller_mixin.rb', line 23 def new @user = User.new respond_with @user do |format| format.html { render :layout => false } end end |
#show ⇒ Object
18 19 20 21 |
# File 'lib/double_auth_engine/controllers/users_controller_mixin.rb', line 18 def show @user = User.find(params[:id]) respond_with @user end |
#update ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/double_auth_engine/controllers/users_controller_mixin.rb', line 45 def update @user = User.find(params[:id]) if @user.update_attributes(params[:user]) flash[:notice] = 'User successfully updated' respond_with(@user) else render :action => 'edit' end end |
#update_password ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/double_auth_engine/controllers/users_controller_mixin.rb', line 64 def update_password @user = User.find(params[:id]) if @user.valid_password? params[:current_password] @user.password = params[:password] @user.password_confirmation = params[:password_confirmation] if @user.save flash[:notice] = "Your password has been updated" redirect_to user_path(@user) else flash[:error] = @user.errors..first render :action => "change_password" end else flash[:error] = "Your Current Password Does not Match" render :action => "change_password" end end |