-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TB-2 #time 30m Add admin profile editor
- Loading branch information
1 parent
10e6992
commit 0273c31
Showing
4 changed files
with
85 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class Hq::ProfileController < Hq::ApplicationController | ||
before_action :set_admin, only: [:edit, :update] | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @admin.valid_password? params[:admin][:current_password] && @admin.update(admin_params) | ||
sign_in @admin | ||
redirect_to hq_dashboard_index_path | ||
else | ||
render 'edit' | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_admin | ||
@admin = current_admin | ||
end | ||
|
||
def admin_params | ||
params.require(:admin).permit(:email, :password, :password_confirmation) | ||
end | ||
end | ||
This comment has been minimized.
Sorry, something went wrong. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.panel.panel-default | ||
.panel-heading | ||
%i.icon-edit.icon-large | ||
#{t('edit_profile')} | ||
.panel-body | ||
= simple_form_for :admin, method: :put, url: '/hq/profile' do |f| | ||
= f.error_notification | ||
|
||
.form-inputs | ||
= f.input :email | ||
= f.input :password | ||
= f.input :password_confirmation | ||
= f.input :current_password | ||
|
||
.form-actions | ||
= f.button :submit, class: 'btn btn-default' | ||
= link_to t('cancel'), hq_dashboard_index_path, class: 'btn' |
@marjinal1st We need AdminProfile and UserProfile model. And we must edit it.