mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Add tests to user model and admin panel requests
This commit is contained in:
@@ -32,9 +32,12 @@ module Admin
|
||||
# for more information
|
||||
|
||||
def authenticate_admin
|
||||
super # apply the generic rules for authentication in the admin panel...
|
||||
|
||||
# ...plus this one
|
||||
unless user_signed_in?
|
||||
flash[:alert] = "You must be logged in to access this page."
|
||||
redirect_to new_user_session_path
|
||||
return
|
||||
end
|
||||
|
||||
unless current_user.admin?
|
||||
flash[:alert] = "You do not have the privilegies to access this page."
|
||||
redirect_to root_path
|
||||
|
||||
@@ -6,7 +6,7 @@ class User < ApplicationRecord
|
||||
enum role: [:user, :moderator, :admin]
|
||||
after_initialize :set_default_role, if: :new_record?
|
||||
|
||||
validates :full_name, presence: true
|
||||
validates :full_name, presence: true, length: { in: 2..32 }
|
||||
|
||||
def set_default_role
|
||||
self.role ||= :user
|
||||
|
||||
Reference in New Issue
Block a user