Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
V
Venjob
  • Overview
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 2
    • Merge Requests 2
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Hoang Nam Nguyen
  • Venjob
  • Merge Requests
  • !5

Merged
Opened Sep 29, 2017 by Hoang Nam Nguyen@namnh 
  • Report abuse
Report abuse

WIP: Forgot password page

×

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b forgot_password_page origin/forgot_password_page

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git checkout master
git merge --no-ff forgot_password_page

Step 4. Push the result of the merge to GitLab

git push origin master

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 23
  • Commits 4
  • Changes 23
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • Hoang Nam Nguyen @namnh

    added 6 commits

    • 4471d916 - 'finish search solr and fix bootstrap'
    • d0151290 - 'register_page'
    • bc3c4cb0 - 'add more bootstrap'
    • 2baa6eb2 - 'Fix register page'
    • 90169376 - 'Finish register,login pages'
    • 19d7354b - 'fix miss and finish forgot_page'

    Compare with previous version

    Sep 29, 2017

    added 6 commits

    • 4471d916 - 'finish search solr and fix bootstrap'
    • d0151290 - 'register_page'
    • bc3c4cb0 - 'add more bootstrap'
    • 2baa6eb2 - 'Fix register page'
    • 90169376 - 'Finish register,login pages'
    • 19d7354b - 'fix miss and finish forgot_page'

    Compare with previous version

    added 6 commits * 4471d916 - 'finish search solr and fix bootstrap' * d0151290 - 'register_page' * bc3c4cb0 - 'add more bootstrap' * 2baa6eb2 - 'Fix register page' * 90169376 - 'Finish register,login pages' * 19d7354b - 'fix miss and finish forgot_page' [Compare with previous version](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3646&start_sha=91e3d5533fbec2d70d83417d190a61518cdc766d)
    Toggle commit list
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/controllers/users_controller.rb
    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)
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh use update_attributes or update http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes

      @namnh use `update_attributes` or `update` http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      yes. tks

      yes. tks
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      i fixed

      i fixed
    • Hoang Nam Nguyen @namnh

      changed this line in version 3 of the diff

      Oct 03, 2017

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3678&start_sha=19d7354b9df62be4fd88e37b30369a8f8d92024e#28f48e0bc2718ddf87752d15b58a0016c13baf1c_30_30)
      Toggle commit list
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/models/user.rb
    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))
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh use update_attributes or update http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes

      @namnh use `update_attributes` or `update` http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      yes. tks so much

      yes. tks so much
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      i got it

      i got it
    • Hoang Nam Nguyen @namnh

      changed this line in version 3 of the diff

      Oct 03, 2017

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3678&start_sha=19d7354b9df62be4fd88e37b30369a8f8d92024e#4ed0c03b53dbc8320da88e7887465514cd9e90a4_27_26)
      Toggle commit list
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/models/user.rb
    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
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh generate_token

      @namnh `generate_token`
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      Yes. i check now

      Yes. i check now
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      i fixed

      i fixed
    • Hoang Nam Nguyen @namnh

      changed this line in version 3 of the diff

      Oct 03, 2017

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3678&start_sha=19d7354b9df62be4fd88e37b30369a8f8d92024e#4ed0c03b53dbc8320da88e7887465514cd9e90a4_66_66)
      Toggle commit list
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/views/job/detail.html.erb
    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>
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh should use simple_format http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-simple_format

      @namnh should use `simple_format` http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-simple_format
    • Hoang Nam Nguyen @namnh

      changed this line in version 3 of the diff

      Oct 03, 2017

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3678&start_sha=19d7354b9df62be4fd88e37b30369a8f8d92024e#2a9478fac5c799980a15fee5575206c82471e89d_23_23)
      Toggle commit list
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    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'%>
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh fix indent

      @namnh fix indent
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      i fixed

      i fixed
    • Hoang Nam Nguyen @namnh

      changed this line in version 3 of the diff

      Oct 03, 2017

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3678&start_sha=19d7354b9df62be4fd88e37b30369a8f8d92024e#f2060791972a109c80d6e3353e44c67de52af08c_7_7)
      Toggle commit list
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/models/user.rb
    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
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh why do we need to digest the reset_token?

      @namnh why do we need to `digest` the `reset_token`?
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      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

      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
    • Hoang Nam Nguyen @namnh

      changed this line in version 3 of the diff

      Oct 03, 2017

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3678&start_sha=19d7354b9df62be4fd88e37b30369a8f8d92024e#4ed0c03b53dbc8320da88e7887465514cd9e90a4_26_26)
      Toggle commit list
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/models/user.rb
    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 }
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh is it the same as Line#20?

      @namnh is it the same as Line#20?
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      i remoted

      i remoted
    • Hoang Nam Nguyen @namnh

      changed this line in version 4 of the diff

      Oct 03, 2017

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3679&start_sha=192494b526dfceaaa075f54ee4eb0ac01e71b423#4ed0c03b53dbc8320da88e7887465514cd9e90a4_22_22)
      Toggle commit list
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/controllers/password_resets_controller.rb 0 → 100644
    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
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh this method should not belongs to model. It should be put in controller.

      @namnh this method should not belongs to model. It should be put in controller.
    • Hoang Nam Nguyen @namnh

      changed this line in version 3 of the diff

      Oct 03, 2017

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3678&start_sha=19d7354b9df62be4fd88e37b30369a8f8d92024e#f6daeca7322bed5d7805a4a5ef314100f88fb69b_13_13)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Nam Nguyen @namnh

    added 1 commit

    • 192494b5 - 'fixed forgot_page'

    Compare with previous version

    Oct 03, 2017

    added 1 commit

    • 192494b5 - 'fixed forgot_page'

    Compare with previous version

    added 1 commit * 192494b5 - &#x27;fixed forgot_page&#x27; [Compare with previous version](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3678&start_sha=19d7354b9df62be4fd88e37b30369a8f8d92024e)
    Toggle commit list
  • Hoang Nam Nguyen @namnh

    added 1 commit

    • 2bd3583d - fixef forgot_page

    Compare with previous version

    Oct 03, 2017

    added 1 commit

    • 2bd3583d - fixef forgot_page

    Compare with previous version

    added 1 commit * 2bd3583d - fixef forgot_page [Compare with previous version](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3679&start_sha=192494b526dfceaaa075f54ee4eb0ac01e71b423)
    Toggle commit list
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/controllers/password_resets_controller.rb 0 → 100644
    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]
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh before_action :get_user, :valid_user, :check_expiration, only: [:edit, :update]

      @namnh `before_action :get_user, :valid_user, :check_expiration, only: [:edit, :update]`
    • Hoang Nam Nguyen @namnh

      changed this line in version 5 of the diff

      Oct 03, 2017

      changed this line in version 5 of the diff

      changed this line in [version 5 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3682&start_sha=2bd3583d393637d3040fa886718111598baaab2c#f6daeca7322bed5d7805a4a5ef314100f88fb69b_4_2)
      Toggle commit list
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      tks so much

      tks so much
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/controllers/users_controller.rb
    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)
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh please carefully read the document of update_attributes again. http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes

      @namnh please carefully read the document of `update_attributes` again. http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes
    • Hoang Nam Nguyen @namnh

      changed this line in version 5 of the diff

      Oct 03, 2017

      changed this line in version 5 of the diff

      changed this line in [version 5 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3682&start_sha=2bd3583d393637d3040fa886718111598baaab2c#28f48e0bc2718ddf87752d15b58a0016c13baf1c_30_30)
      Toggle commit list
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      tks so much

      tks so much
    Please register or sign in to reply
  • Vinh Nguyen
    @vinhnx started a discussion on an old version of the diff Oct 03, 2017
    Last updated by Hoang Nam Nguyen Oct 03, 2017
    app/models/user.rb
    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))
    • Vinh Nguyen @vinhnx commented Oct 03, 2017

      @namnh please carefully read the document of update_attributes again. http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes

      @namnh please carefully read the document of `update_attributes` again. http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attributes
    • Hoang Nam Nguyen @namnh

      changed this line in version 5 of the diff

      Oct 03, 2017

      changed this line in version 5 of the diff

      changed this line in [version 5 of the diff](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3682&start_sha=2bd3583d393637d3040fa886718111598baaab2c#4ed0c03b53dbc8320da88e7887465514cd9e90a4_26_26)
      Toggle commit list
    • Hoang Nam Nguyen @namnh commented Oct 03, 2017
      Master

      tks so much

      tks so much
    Please register or sign in to reply
  • Hoang Nam Nguyen @namnh

    added 1 commit

    • e89b7f9f - 'fixed again'

    Compare with previous version

    Oct 03, 2017

    added 1 commit

    • e89b7f9f - 'fixed again'

    Compare with previous version

    added 1 commit * e89b7f9f - &#x27;fixed again&#x27; [Compare with previous version](https://gitlab.zigexn.vn/namnh/Venjob/merge_requests/5/diffs?diff_id=3682&start_sha=2bd3583d393637d3040fa886718111598baaab2c)
    Toggle commit list
  • Hoang Nam Nguyen @namnh

    merged

    Oct 05, 2017

    merged

    merged
    Toggle commit list
  • Write
  • Preview
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 sign in to comment
Assignee
No assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
2
2 participants
Reference: namnh/Venjob!5