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.
-
#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!, #build_model_from_params, #check_for_create, #check_for_destroy, #check_for_update, #from_bson, #from_view, #get_model_class_name, #instantiate_classes, #not_found
Instance Method Details
#create ⇒ Object
User.where(:email => “[email protected]”).first.delete POST /auth/admin_create_users
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 48 def create k = SecureRandom.hex(24) @auth_user.password = k @auth_user.password_confirmation = k @auth_user.m_client = self.m_client @auth_user.created_by_admin = true 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
78 79 80 81 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 78 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
43 44 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 43 def edit end |
#index ⇒ Object
GET /auth/admin_create_users
26 27 28 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 26 def index #@auth_admin_create_users = Auth::AdminCreateUser.all end |
#initialize_vars ⇒ Object
called before all the actions.
15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 15 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(params[:id]) : @auth_user_class.new(@auth_user_params) end |
#new ⇒ Object
GET /auth/admin_create_users/new
35 36 37 38 39 40 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 35 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
83 84 85 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 83 def permitted_params params.permit({user: ([:email,:additional_login_param, :password, :password_confirmation] + Devise::ParameterSanitizer::DEFAULT_PERMITTED_ATTRIBUTES[:account_update]).uniq},:id) end |
#show ⇒ Object
GET /auth/admin_create_users/1
31 32 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 31 def show end |
#update ⇒ Object
PATCH/PUT /auth/admin_create_users/1
71 72 73 74 75 |
# File 'app/controllers/auth/admin_create_users_controller.rb', line 71 def update ## should also allow stuff like ## resend sms otp ## resend confirmation email end |