WIP: Forgot password page
-
25 25 @user = User.find(params[:id]) 26 26 @user.validate_name = true 27 27 @user.validate_password = true 28 uploadedFile = params[:user][:cv] 29 File.open(Rails.root.join('public','cv',uploadedFile.original_filename), 'wb') do |f| 30 f.write(uploadedFile.read) 31 end 28 32 29 if @user.update_attributes(user_params) 33 flash[:success] = "Sign up success" 30 @user.update_attribute(:activated, true) -
@namnh use
update_attributesorupdatehttp://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes -
Master
yes. tks
-
Master
i fixed
-
-
-
10 has_secure_password(validations: false) 11 validates :password, presence: true, length: { minimum: 5}, if: :validate_password 14 15 with_options unless: :new_record? do |opts| 16 opts.validates :password, presence: true, length: { maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED,minimum: 6 } 17 opts.validates_confirmation_of :password, allow_blank: true 18 end 19 20 before_save :downcase_email 21 before_save :set_password 22 before_save { self.email = email.downcase } 23 before_create :create_activation_digest 24 25 def create_reset_digest 26 self.reset_token = new_token 27 update_attribute(:reset_digest, digest(reset_token)) -
@namnh use
update_attributesorupdatehttp://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes -
Master
yes. tks so much
-
Master
i got it
-
-
-
51 def password_reset_expired? 52 reset_sent_at < 1.day.ago 53 end 54 55 private 56 57 def downcase_email 58 self.email = email.downcase 59 end 60 61 def create_activation_digest 62 self.activation_token = new_token 63 self.activation_digest = digest(activation_token) 64 end 65 66 def new_token -
18 18 </div> 19 19 <div class="card-body"> 20 20 <h4 class="card-title text-primary"><%= @job.company.company_name %></h4> 21 <p class="card-texts">Location: <%= @job.cities.map {|l| l.location}.join(',') %></p> 21 <p class="card-texts">Location: <%= @job.cities.map(&:location).join(',') %></p> 22 22 <p class="card-text"><a href="#">Salary: </a><%= @job.salary %></p> 23 23 <p class="card-text"><%= @job.descripton.gsub("\t"," ").gsub("\n","<br/>").gsub("\r","<br/>").html_safe %></p> -
@namnh should use
simple_formathttp://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-simple_format -
-
-
app/views/password_resets/edit.html.erb 0 → 100644
1 <% provide(:title, 'New Password') %> 2 <h1 class="text-primary text-center mt-5">Forgot Password</h1> 3 4 <div class="row ml-5"> 5 <div class="col-md-10 col-md-offset-3"> 6 <%= form_for(@user, url: password_reset_path(params.permit(:email, :id, :reset_digest))) do |f| %> 7 <%= render 'shared/error_messages'%> -
Master
i fixed
-
-
9 13 uniqueness: {case_sensitive: false} 10 has_secure_password(validations: false) 11 validates :password, presence: true, length: { minimum: 5}, if: :validate_password 14 15 with_options unless: :new_record? do |opts| 16 opts.validates :password, presence: true, length: { maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED,minimum: 6 } 17 opts.validates_confirmation_of :password, allow_blank: true 18 end 19 20 before_save :downcase_email 21 before_save :set_password 22 before_save { self.email = email.downcase } 23 before_create :create_activation_digest 24 25 def create_reset_digest 26 self.reset_token = new_token -
Master
because I want to create random string and save in database with name reset token ... when i reset passwork... i compare reset_token and digest if true we'll accept password reset. f
-
-
5 9 validates :name, presence: true, length: { maximum: 200 }, if: :validate_name 6 10 VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i 7 11 validates :email, presence: true, length: {maximum: 255}, 8 12 format: {with: VALID_EMAIL_REGEX }, 9 13 uniqueness: {case_sensitive: false} 10 has_secure_password(validations: false) 11 validates :password, presence: true, length: { minimum: 5}, if: :validate_password 14 15 with_options unless: :new_record? do |opts| 16 opts.validates :password, presence: true, length: { maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED,minimum: 6 } 17 opts.validates_confirmation_of :password, allow_blank: true 18 end 19 20 before_save :downcase_email 21 before_save :set_password 22 before_save { self.email = email.downcase } -
Master
i remoted
-
-
1 class PasswordResetsController < ApplicationController 2 before_action :get_user, only: [:edit, :update] 3 before_action :valid_user, only: [:edit, :update] 4 before_action :check_expiration, only: [:edit, :update] 5 6 def new 7 end 8 9 def create 10 @user = User.find_by(email: params[:password_reset][:email].downcase) 11 if @user 12 @user.create_reset_digest 13 @user.send_password_reset_email -
-
-
1 class PasswordResetsController < ApplicationController 2 before_action :get_user, only: [:edit, :update] 3 before_action :valid_user, only: [:edit, :update] 4 before_action :check_expiration, only: [:edit, :update] -
-
Master
tks so much
-
25 25 @user = User.find(params[:id]) 26 26 @user.validate_name = true 27 27 @user.validate_password = true 28 uploadedFile = params[:user][:cv] 29 File.open(Rails.root.join('public','cv',uploadedFile.original_filename), 'wb') do |f| 30 f.write(uploadedFile.read) 31 end 28 32 29 if @user.update_attributes(user_params) 33 flash[:success] = "Sign up success" 30 @user.update_attributes(:activated => true) -
@namnh please carefully read the document of
update_attributesagain. http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes -
-
Master
tks so much
-
-
9 13 uniqueness: {case_sensitive: false} 10 has_secure_password(validations: false) 11 validates :password, presence: true, length: { minimum: 5}, if: :validate_password 14 15 with_options unless: :new_record? do |opts| 16 opts.validates :password, presence: true, length: { maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED,minimum: 6 } 17 opts.validates_confirmation_of :password, allow_blank: true 18 end 19 20 before_save :downcase_email 21 before_save :set_password 22 before_create :create_activation_digest 23 24 def create_reset_digest 25 self.reset_token = generate_token 26 update_attributes(:reset_digest => digest(reset_token)) -
@namnh please carefully read the document of
update_attributesagain. http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes -
-
Master
tks so much
-
-
-
merged
Toggle commit list