Commit f87141f5 by Quang Vinh Nguyen

add random password

parent 13c666b9
......@@ -27,13 +27,19 @@ class EntriesController < ApplicationController
@job = Job.find(params[:job_id])
@user = User.find_by(email: params[:entry][:entry_email]) ||
User.create( name: params[:entry][:entry_name],
random_password = Devise.friendly_token
if @user = User.find_by(email: params[:entry][:entry_email])
else
@user = User.new( name: params[:entry][:entry_name],
email: params[:entry][:entry_email],
phone: params[:entry][:entry_phone],
address: params[:entry][:entry_address])#,
# password: 'password',
# password_confirmation: 'password')
address: params[:entry][:entry_address],
password: random_password,
password_confirmation: random_password)
@user.skip_confirmation!
@user.save!
end
@entry.user_id = @user.id
@entry.job_id = @job.id
......
......@@ -4,8 +4,8 @@ class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable#,
# :confirmable
:recoverable, :rememberable, :validatable,
:confirmable
has_many :favorite_jobs, dependent: :destroy
......@@ -13,7 +13,7 @@ class User < ApplicationRecord
dependent: :destroy
has_many :jobs, through: :entries
validates :name, presence: true, length: { maximum: 255 }
# validates :name, presence: true, length: { maximum: 255 }
# validates :prefix, presence: true
......@@ -27,8 +27,9 @@ class User < ApplicationRecord
validates :password, presence: true, length: { minimum: 8 }
# Sends activation email.
# Sends apply email.
def send_job_apply_email(job)
UserMailer.job_apply(self, job).deliver_now
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment