Class: Mori::InvitesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Mori::InvitesController
- Defined in:
- app/controllers/mori/invites_controller.rb
Overview
Mori::InvitesController handles the sending and acceping of invitations
Instance Method Summary collapse
- #accept ⇒ Object
- #invitation_conditions(user) ⇒ Object
- #new ⇒ Object
- #send_user ⇒ Object
- #show ⇒ Object
Methods inherited from BaseController
Instance Method Details
#accept ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/mori/invites_controller.rb', line 17 def accept user = @config.user_model.find_by_invitation_token(@token) if invitation_conditions(user) user.accept_invitation(user_params[:password]) warden.authenticate! redirect_to @config.dashboard_path, :notice => I18n.t('flashes.logged_in') else flash[:notice] = I18n.t('flashes.invalid_invitation_token') redirect_to invite_path(@token) end end |
#invitation_conditions(user) ⇒ Object
39 40 41 |
# File 'app/controllers/mori/invites_controller.rb', line 39 def invitation_conditions(user) user.invitation_sent > Mori::Token.expiration_date end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/mori/invites_controller.rb', line 13 def new render :template => 'invites/new' end |
#send_user ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/mori/invites_controller.rb', line 29 def send_user valid, = @config.user_model.invite(params[:email]) flash[:notice] = if valid redirect_to @config.dashboard_path else render :template => 'invites/new' end end |
#show ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'app/controllers/mori/invites_controller.rb', line 4 def show @user = @config.user_model.find_by_invitation_token(params[:id]) if @user render :template => 'invites/show' else redirect_to root_path end end |