Class: Auth::AdminCreateUsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Auth::AdminCreateUsersController
- Includes:
- Concerns::DeviseConcern, Concerns::TokenConcern
- Defined in:
- app/controllers/auth/admin_create_users_controller.rb
Constant Summary collapse
- CONDITIONS_FOR_TOKEN_AUTH =
only these actions need an authenticated user to be present for them to be executed.
[:create,:update,:destroy,:edit,:new,:index,:show]
- TCONDITIONS =
{:only => CONDITIONS_FOR_TOKEN_AUTH}
Instance Method Summary collapse
-
#create ⇒ Object
User.where(:email => “[email protected]”).first.delete POST /auth/admin_create_users.
-
#destroy ⇒ Object
DELETE /auth/admin_create_users/1.
-
#edit ⇒ Object
GET /auth/admin_create_users/1/edit.
-
#index ⇒ Object
GET /auth/admin_create_users.
-
#initialize_vars ⇒ Object
called before all the actions.
-
#is_admin_user ⇒ Object
ensures that only admin users.
-
#new ⇒ Object
GET /auth/admin_create_users/new.
- #permitted_params ⇒ Object
-
#show ⇒ Object
GET /auth/admin_create_users/1.
-
#update ⇒ Object
PATCH/PUT /auth/admin_create_users/1.
Methods inherited from ApplicationController
#authenticate_resource!, #check_for_create, #check_for_destroy, #check_for_update, #from_bson, #from_view, #not_found
Instance Method Details
#create ⇒ Object
User.where(:email => “[email protected]”).first.delete POST /auth/admin_create_users
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 47 def create @auth_user.password = @auth_user.password_confirmation =SecureRandom.hex(24) @auth_user.m_client = self.m_client @auth_user.created_by_admin = true ## we will have to set the m_client. ## but what if that client is different from the client that was used to create the user? ## no this will not happen here. ## here we will only create. respond_to do |format| if @auth_user.save if !@auth_user.additional_login_param.blank? format.html {render "auth/confirmations/enter_otp.html.erb"} format.json {render json: @auth_user.to_json, status: :created} else format.html {render "auth/admin_create_users/show.html.erb"} format.json {render json: @auth_user.to_json, status: :created} end else format.html {render "new.html.erb"} format.json {render json: {:errors => @auth_user.errors}, status: 422} end end end |
#destroy ⇒ Object
DELETE /auth/admin_create_users/1
80 81 82 83 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 80 def destroy @auth_admin_create_user.destroy redirect_to auth_admin_create_users_url, notice: 'Admin create user was successfully destroyed.' end |
#edit ⇒ Object
GET /auth/admin_create_users/1/edit
42 43 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 42 def edit end |
#index ⇒ Object
GET /auth/admin_create_users
25 26 27 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 25 def index #@auth_admin_create_users = Auth::AdminCreateUser.all end |
#initialize_vars ⇒ Object
called before all the actions.
14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 14 def initialize_vars @auth_user_class = Auth.configuration.user_class.constantize @auth_user_params = permitted_params.fetch(:user,{}) @auth_user = params[:id] ? @auth_user_class.find_self(params[:id],current_signed_in_resource) : @auth_user_class.new(@auth_user_params) end |
#is_admin_user ⇒ Object
ensures that only admin users.
10 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 10 before_filter :is_admin_user , TCONDITIONS |
#new ⇒ Object
GET /auth/admin_create_users/new
34 35 36 37 38 39 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 34 def new # what kind of form should be presented to the admin. #@auth_admin_create_user = Auth::AdminCreateUser.new ## just render a form with the user model. end |
#permitted_params ⇒ Object
85 86 87 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 85 def permitted_params params.permit({user: [:email,:additional_login_param, :password, :password_confirmation]},:id) end |
#show ⇒ Object
GET /auth/admin_create_users/1
30 31 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 30 def show end |
#update ⇒ Object
PATCH/PUT /auth/admin_create_users/1
73 74 75 76 77 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 73 def update ## should also allow stuff like ## resend sms otp ## resend confirmation email end |