Install devise invitable
Devise invitable gem is required to invite users.
This commit is contained in:
parent
a20c1bb882
commit
04c3859526
11 changed files with 171 additions and 3 deletions
|
|
@ -9,6 +9,8 @@ class ApplicationController < ActionController::Base
|
|||
# Ensure every controller authorizes resource or skips authorization (skip_authorization_check)
|
||||
check_authorization unless: :devise_controller?
|
||||
|
||||
before_action :devise_configure_permitted_parameters, if: :devise_controller?
|
||||
|
||||
def store_location
|
||||
# store last url - this is needed for post-login redirect to whatever the user last visited.
|
||||
return unless request.get?
|
||||
|
|
@ -65,4 +67,8 @@ class ApplicationController < ActionController::Base
|
|||
def not_found
|
||||
raise ActionController::RoutingError.new('Not Found')
|
||||
end
|
||||
|
||||
def devise_configure_permitted_parameters
|
||||
devise_parameter_sanitizer.permit(:accept_invitation, keys: [:username])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ class User < ApplicationRecord
|
|||
[:ichain_authenticatable, :ichain_registerable, :omniauthable, omniauth_providers: []]
|
||||
else
|
||||
[:database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
|
||||
:omniauthable, omniauth_providers: [:suse, :google, :facebook, :github]]
|
||||
:recoverable, :rememberable, :trackable, :validatable, :invitable,
|
||||
:confirmable, :omniauthable, omniauth_providers: [:suse, :google, :facebook, :github]]
|
||||
end
|
||||
|
||||
devise(*devise_modules)
|
||||
|
|
|
|||
20
app/views/devise/invitations/edit.html.haml
Normal file
20
app/views/devise/invitations/edit.html.haml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
.container
|
||||
.row
|
||||
.col-md-6.col-md-offset-3
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title
|
||||
%h2= t 'devise.invitations.edit.header'
|
||||
.panel-body
|
||||
= form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put }) do |f|
|
||||
= render 'devise/shared/error_messages', resource: resource
|
||||
= f.hidden_field :invitation_token, readonly: true
|
||||
- if f.object.class.require_password_on_accepting
|
||||
= f.label :username
|
||||
= f.text_field :username, class: 'form-control'
|
||||
= f.label :password
|
||||
= f.password_field :password, class: 'form-control'
|
||||
= f.label :password_confirmation
|
||||
= f.password_field :password_confirmation, class: 'form-control'
|
||||
%br
|
||||
= f.submit t('devise.invitations.edit.submit_button'), class: 'btn btn-default btn-primary'
|
||||
11
app/views/devise/mailer/invitation_instructions.html.erb
Normal file
11
app/views/devise/mailer/invitation_instructions.html.erb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<p><%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %></p>
|
||||
|
||||
<p><%= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) %></p>
|
||||
|
||||
<p><%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, invitation_token: @token) %></p>
|
||||
|
||||
<% if @resource.invitation_due_at %>
|
||||
<p><%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %></p>
|
||||
<% end %>
|
||||
|
||||
<p><%= t("devise.mailer.invitation_instructions.ignore") %></p>
|
||||
11
app/views/devise/mailer/invitation_instructions.text.erb
Normal file
11
app/views/devise/mailer/invitation_instructions.text.erb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %>
|
||||
|
||||
<%= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) %>
|
||||
|
||||
<%= accept_invitation_url(@resource, invitation_token: @token) %>
|
||||
|
||||
<% if @resource.invitation_due_at %>
|
||||
<%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %>
|
||||
<% end %>
|
||||
|
||||
<%= t("devise.mailer.invitation_instructions.ignore") %>
|
||||
Loading…
Add table
Add a link
Reference in a new issue