Allow admin to create new user identities
This commit is contained in:
parent
2b4a3bc524
commit
577448ab6a
4 changed files with 22 additions and 2 deletions
|
@ -1,6 +1,21 @@
|
|||
class Admin::IdentitiesController < Admin::ApplicationController
|
||||
before_action :user
|
||||
before_action :identity, except: :index
|
||||
before_action :identity, except: [:index, :new, :create]
|
||||
|
||||
def new
|
||||
@identity = Identity.new
|
||||
end
|
||||
|
||||
def create
|
||||
@identity = Identity.new(identity_params)
|
||||
@identity.user_id = user.id
|
||||
|
||||
if @identity.save
|
||||
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully created.'
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
@identities = @user.identities
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
- page_title "Identities", @user.name, "Users"
|
||||
= render 'admin/users/head'
|
||||
|
||||
= link_to 'New Identity', new_admin_user_identity_path, class: 'pull-right btn btn-new'
|
||||
- if @identities.present?
|
||||
.table-holder
|
||||
%table.table
|
||||
|
|
4
app/views/admin/identities/new.html.haml
Normal file
4
app/views/admin/identities/new.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- page_title "New Identity"
|
||||
%h3.page-title New identity
|
||||
%hr
|
||||
= render 'form'
|
|
@ -188,7 +188,7 @@ Rails.application.routes.draw do
|
|||
namespace :admin do
|
||||
resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
|
||||
resources :keys, only: [:show, :destroy]
|
||||
resources :identities, only: [:index, :edit, :update, :destroy]
|
||||
resources :identities, except: [:show]
|
||||
|
||||
delete 'stop_impersonation' => 'impersonation#destroy', on: :collection
|
||||
|
||||
|
|
Loading…
Reference in a new issue