lib/hippo/user.rb in hippo-fw-0.9.1 vs lib/hippo/user.rb in hippo-fw-0.9.2

- old
+ new

@@ -1,14 +1,17 @@ require 'jwt' module Hippo class User < Hippo::Model - + belongs_to_tenant has_secure_password - validates :login, :name, :email, presence: true, uniqueness: { case_sensitive: false } - validates :email, email: true, uniqueness: { case_sensitive: false } + validates :login, :name, presence: true, + uniqueness: { scope: :tenant, case_sensitive: false } + validates :email, presence: true, email: true, + uniqueness: { scope: :tenant, case_sensitive: false } + validates :password, length: { minimum: 6 }, allow_nil: true whitelist_attributes :password def roles @@ -135,12 +138,15 @@ ensure Thread.current[:hippo_current_user] = prev_user end def self.seed_admin_account - where(login: 'admin').first || create!(name: "Admin", email: "admin@test.com", - password: 'password', - login: 'admin', role_names: ['administrator']) + where(login: 'admin').first || + create!( + name: "Admin", email: "admin@test.com", + password: 'password', + login: 'admin', role_names: ['administrator'] + ) end end require_relative "access/track_modifications"