-
Notifications
You must be signed in to change notification settings - Fork 45
Guest users and accounts
CanTango operates with the concepts of a Guest user and a Guest account.
In case the current_xxx_
method doesn't return a valid user, Cantango will attempt to return
a guest user according to Configuration and conventions.
If Cantango has not been configured with a specific Guest user configuration, it will see if the User model
is available. If so, it will call #guest
on it (if method available).
class User
def self.guest
@guest ||= Guest.new
end
end
Note that the Guest user should normally not be a persisted model.
Cantango should be configured with how to retrieve (or create) such a guest user via:
CanTango::Configuration.guest.user obj
The obj
argument can be either:
- a User instance
- A procedure in the form of a lambda or Proc
- A block
The Guest user should normally have restricted permission rules, mostly only :read access.
We recommend setting the Guest permission rules to: can :read, :all
and refine from there.
In case the current_xxx_account
method doesn't return a valid user account, Cantango will attempt to return
a guest user account according to Configuration and conventions.
If Cantango has not been configured with specific Guest user account configuration, it will
see if the UserAccount model is available. If so, it will call #guest
on it (if method available).
Cantango should be configured with how to retrieve (or create) such a guest user via:
CanTango::Configuration.guest.account obj
The obj
argument can be either:
- UserAccount instance
- A procedure in the form of a lambda or Proc
- A block
The Guest user account should usually be setup to have a guest user only.