This commit is contained in:
Nicolas Bally 2019-04-24 19:07:53 +02:00
parent a7cb020815
commit 2542759620
2 changed files with 16 additions and 1 deletions

View File

@ -16,7 +16,7 @@ class Admin::AdminsController < ApplicationController
def new
@admin = Admin.new
@admin = Admin.new(:contact_role => true)
end

View File

@ -26,6 +26,21 @@ class Admin < ActiveRecord::Base
before_create { generate_token(:remember_token) }
before_validation do
if self.generate_mdp == "1" and (self.password.to_s == "")
self.password = "123456"
end
end
def mdp_needed?
if generate_mdp == "1"
true
else
false
end
end
def generate_mdp_now
ps = SecureRandom.hex(4)
self.password = ps