Class: Kryptonite::UsersController
Instance Method Summary
collapse
#blank
#kryptonite_config_dashboard_url, #kryptonite_config_email_from_address, #kryptonite_config_hostname, #kryptonite_config_javascript_includes, #kryptonite_config_logo, #kryptonite_config_stylesheet_includes, #kryptonite_config_website_name
#kryptonite_assets_field, #kryptonite_check_box, #kryptonite_check_box_group, #kryptonite_collection_select, #kryptonite_date_select, #kryptonite_datetime_select, #kryptonite_file_field, #kryptonite_generate_page_title, #kryptonite_get_access_level_array, #kryptonite_get_access_level_text, #kryptonite_get_full_version_string, #kryptonite_get_language_array, #kryptonite_get_short_version_string, #kryptonite_get_version_info, #kryptonite_hidden_field, #kryptonite_password_field, #kryptonite_radio_button, #kryptonite_radio_button_group, #kryptonite_select, #kryptonite_show_icon, #kryptonite_show_row_icon, #kryptonite_table_cell_link, #kryptonite_table_cell_no_link, #kryptonite_text_area, #kryptonite_text_area_big, #kryptonite_text_field, #kryptonite_time_select, #kryptonite_time_zone_select
Instance Method Details
#create ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/kryptonite/users_controller.rb', line 20
def create
@kryptonite_user = Kryptonite::User.new params[:kryptonite_user]
if @kryptonite_user.save
flash[:notice] = t("users_email_sent_with_details", :username=>@kryptonite_user.name)
redirect_to kryptonite_users_path
else
flash.now[:warning] = t("users_problems_saving_warning")
render :action => :new
end
end
|
#destroy ⇒ Object
92
93
94
95
96
97
98
99
|
# File 'app/controllers/kryptonite/users_controller.rb', line 92
def destroy
user = Kryptonite::User.find params[:id]
if user.is_admin? == false || Kryptonite::User.has_more_than_one_admin
user.destroy
flash[:notice] = t("users_deleted", :username=>user.name)
end
redirect_to kryptonite_users_path
end
|
#index ⇒ Object
9
10
11
12
|
# File 'app/controllers/kryptonite/users_controller.rb', line 9
def index
@kryptonite_page_title = t("users_page_title")
@users = Kryptonite::User.paginate :order => "login", :page => params[:page]
end
|
#new ⇒ Object
14
15
16
17
18
|
# File 'app/controllers/kryptonite/users_controller.rb', line 14
def new
@kryptonite_page_title = t("users_add_new")
@kryptonite_user = Kryptonite::User.new
@kryptonite_user.time_zone = Rails.configuration.time_zone
end
|
#reset_password ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'app/controllers/kryptonite/users_controller.rb', line 73
def reset_password
@kryptonite_user = Kryptonite::User.find params[:id]
@kryptonite_page_title = @kryptonite_user.name + " | " + t("users_reset_password")
@kryptonite_user.notify_of_new_password = true unless @kryptonite_user.id == @session_user.id
if @kryptonite_user.update_attributes params[:kryptonite_user]
if @kryptonite_user.id == @session_user.id
flash.now[:notice] = t("users_password_reseted")
else
flash.now[:notice] = t("users_password_reseted_and_emailed", :username=>@kryptonite_user.name)
end
else
flash.now[:warning] = t("users_problems_reseting_password")
end
render :action => :show
end
|
#show ⇒ Object
32
33
34
35
|
# File 'app/controllers/kryptonite/users_controller.rb', line 32
def show
@kryptonite_user = Kryptonite::User.find params[:id]
@kryptonite_page_title = @kryptonite_user.name + " | " + t("users_show")
end
|
#update ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/kryptonite/users_controller.rb', line 37
def update
@kryptonite_user = Kryptonite::User.find params[:id]
@kryptonite_page_title = @kryptonite_user.name + " | " + t("users_update")
if @kryptonite_user.update_attributes params[:kryptonite_user]
flash[:notice] = t("users_updated_notice", :username=>@kryptonite_user.name)
else
flash.now[:warning] = t("users_problems_updating")
render :action => :show
return
end
if @session_user.is_admin?
redirect_to kryptonite_users_path
else
redirect_to :controller => :kryptonite, :action => :index
end
end
|
#update_password ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/controllers/kryptonite/users_controller.rb', line 56
def update_password
@kryptonite_user = Kryptonite::User.find params[:id]
@kryptonite_page_title = @kryptonite_user.name + " | " + t("users_update_password")
if @kryptonite_user.valid_password? params[:form_current_password]
if @kryptonite_user.update_attributes params[:kryptonite_user]
flash.now[:notice] = t("users_password_changed_notice")
else
flash.now[:warning] = t("users_problems_changing_password")
end
else
flash.now[:warning] = t("users_password_incorrect")
end
render :action => :show
end
|