Commit 5a376069 by nnnghia98

using devise

parent 2bf8b8d9
Pipeline #236 canceled with stages
in 0 seconds
...@@ -16,14 +16,14 @@ gem 'webpacker', '~> 4.0' ...@@ -16,14 +16,14 @@ gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5' gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7' gem 'jbuilder'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1' gem 'jquery-rails', '4.3.1'
gem 'carrierwave' gem 'carrierwave'
gem 'kaminari' gem 'kaminari'
gem 'sunspot_rails' gem 'sunspot_rails'
gem 'sunspot_solr' gem 'sunspot_solr'
gem 'devise'
# Use Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0' # gem 'redis', '~> 4.0'
# Use Active Model has_secure_password # Use Active Model has_secure_password
......
...@@ -58,6 +58,7 @@ GEM ...@@ -58,6 +58,7 @@ GEM
zeitwerk (~> 2.2) zeitwerk (~> 2.2)
addressable (2.7.0) addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
bcrypt (3.1.13)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.4.5) bootsnap (1.4.5)
msgpack (~> 1.0) msgpack (~> 1.0)
...@@ -79,20 +80,18 @@ GEM ...@@ -79,20 +80,18 @@ GEM
mimemagic (>= 0.3.0) mimemagic (>= 0.3.0)
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
childprocess (3.0.0) childprocess (3.0.0)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5) concurrent-ruby (1.1.5)
crass (1.0.5) crass (1.0.5)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
erubi (1.9.0) erubi (1.9.0)
execjs (2.7.0) faraday (0.17.1)
faraday (0.17.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
ffi (1.11.2) ffi (1.11.3)
globalid (0.4.2) globalid (0.4.2)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
i18n (1.7.0) i18n (1.7.0)
...@@ -122,7 +121,7 @@ GEM ...@@ -122,7 +121,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2) ruby_dep (~> 1.2)
loofah (2.3.1) loofah (2.4.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.1) mail (2.7.1)
...@@ -137,10 +136,11 @@ GEM ...@@ -137,10 +136,11 @@ GEM
minitest (5.13.0) minitest (5.13.0)
msgpack (1.3.1) msgpack (1.3.1)
multipart-post (2.1.1) multipart-post (2.1.1)
mysql2 (0.5.2) mysql2 (0.5.3)
nio4r (2.5.2) nio4r (2.5.2)
nokogiri (1.10.5) nokogiri (1.10.5)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pr_geohash (1.0.0) pr_geohash (1.0.0)
public_suffix (4.0.1) public_suffix (4.0.1)
puma (3.12.1) puma (3.12.1)
...@@ -180,6 +180,9 @@ GEM ...@@ -180,6 +180,9 @@ GEM
rb-inotify (0.10.0) rb-inotify (0.10.0)
ffi (~> 1.0) ffi (~> 1.0)
regexp_parser (1.6.0) regexp_parser (1.6.0)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
rsolr (2.2.1) rsolr (2.2.1)
builder (>= 2.1.2) builder (>= 2.1.2)
faraday (>= 0.9.0) faraday (>= 0.9.0)
...@@ -227,6 +230,8 @@ GEM ...@@ -227,6 +230,8 @@ GEM
turbolinks-source (5.2.0) turbolinks-source (5.2.0)
tzinfo (1.2.5) tzinfo (1.2.5)
thread_safe (~> 0.1) thread_safe (~> 0.1)
warden (1.2.8)
rack (>= 2.0.6)
web-console (4.0.1) web-console (4.0.1)
actionview (>= 6.0.0) actionview (>= 6.0.0)
activemodel (>= 6.0.0) activemodel (>= 6.0.0)
...@@ -255,8 +260,8 @@ DEPENDENCIES ...@@ -255,8 +260,8 @@ DEPENDENCIES
byebug byebug
capybara (>= 2.15) capybara (>= 2.15)
carrierwave carrierwave
coffee-rails (= 4.2.2) devise
jbuilder (~> 2.7) jbuilder
jquery-rails (= 4.3.1) jquery-rails (= 4.3.1)
kaminari kaminari
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
......
class User < ApplicationRecord class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
end end
...@@ -59,4 +59,6 @@ Rails.application.configure do ...@@ -59,4 +59,6 @@ Rails.application.configure do
# Use an evented file watcher to asynchronously detect changes in source code, # Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem. # routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
end end
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
en:
devise:
confirmations:
confirmed: "Your email address has been successfully confirmed."
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
failure:
already_authenticated: "You are already signed in."
inactive: "Your account is not activated yet."
invalid: "Invalid %{authentication_keys} or password."
locked: "Your account is locked."
last_attempt: "You have one more attempt before your account is locked."
not_found_in_database: "Invalid %{authentication_keys} or password."
timeout: "Your session expired. Please sign in again to continue."
unauthenticated: "You need to sign in or sign up before continuing."
unconfirmed: "You have to confirm your email address before continuing."
mailer:
confirmation_instructions:
subject: "Confirmation instructions"
reset_password_instructions:
subject: "Reset password instructions"
unlock_instructions:
subject: "Unlock instructions"
email_changed:
subject: "Email Changed"
password_change:
subject: "Password Changed"
omniauth_callbacks:
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
success: "Successfully authenticated from %{kind} account."
passwords:
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
updated: "Your password has been changed successfully. You are now signed in."
updated_not_active: "Your password has been changed successfully."
registrations:
destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
signed_up: "Welcome! You have signed up successfully."
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
updated: "Your account has been updated successfully."
updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
sessions:
signed_in: "Signed in successfully."
signed_out: "Signed out successfully."
already_signed_out: "Signed out successfully."
unlocks:
send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
unlocked: "Your account has been unlocked successfully. Please sign in to continue."
errors:
messages:
already_confirmed: "was already confirmed, please try signing in"
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
expired: "has expired, please request a new one"
not_found: "not found"
not_locked: "was not locked"
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
other: "%{count} errors prohibited this %{resource} from being saved:"
Rails.application.routes.draw do Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end end
...@@ -3,19 +3,48 @@ class CreateUsers < ActiveRecord::Migration[6.0] ...@@ -3,19 +3,48 @@ class CreateUsers < ActiveRecord::Migration[6.0]
create_table :users do |t| create_table :users do |t|
t.string :first_name t.string :first_name
t.string :last_name t.string :last_name
t.string :email, unique: true
t.string :username, unique: true ## Database authenticatable
t.integer :role t.string :email, null: false, default: ""
t.string :password_digest t.string :username
t.string :reset_digest t.string :encrypted_password, null: false, default: ""
t.datetime :reset_sent_at
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
t.string :remember_digest t.string :remember_digest
t.string :activation_digest
t.datetime :activated_at ## Trackable
# t.integer :sign_in_count, default: 0, null: false
# t.datetime :current_sign_in_at
# t.datetime :last_sign_in_at
# t.string :current_sign_in_ip
# t.string :last_sign_in_ip
# Confirmable
t.string :confirmation_token
t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
t.boolean :activated t.boolean :activated
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.string :cv_path t.string :cv_path
t.integer :role
t.timestamps t.timestamps null: false
end end
add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true
end end
end end
...@@ -91,19 +91,22 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -91,19 +91,22 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "first_name" t.string "first_name"
t.string "last_name" t.string "last_name"
t.string "email" t.string "email", default: "", null: false
t.string "username" t.string "username"
t.integer "role" t.string "encrypted_password", default: "", null: false
t.string "password_digest" t.string "reset_password_token"
t.string "reset_digest" t.datetime "reset_password_sent_at"
t.datetime "reset_sent_at" t.datetime "remember_created_at"
t.string "remember_digest" t.string "remember_digest"
t.string "activation_digest" t.string "confirmation_token"
t.datetime "activated_at" t.datetime "confirmed_at"
t.boolean "activated" t.boolean "activated"
t.string "cv_path" t.string "cv_path"
t.integer "role"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end end
add_foreign_key "city_jobs", "cities" add_foreign_key "city_jobs", "cities"
......
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one: # This model initially had no columns defined. If you add columns to the
first_name: MyString # model remove the '{}' from the fixture names and add the columns immediately
last_name: MyString # below each fixture, per the syntax in the comments below
email: MyString #
username: MyString one: {}
role: 1 # column: value
password_digest: MyString #
reset_digest: MyString two: {}
reset_sent_at: 2019-11-26 15:28:50 # column: value
remember_digest: MyString
activation_digest: MyString
activated_at: 2019-11-26 15:28:50
activated: false
cv_path: MyString
two:
first_name: MyString
last_name: MyString
email: MyString
username: MyString
role: 1
password_digest: MyString
reset_digest: MyString
reset_sent_at: 2019-11-26 15:28:50
remember_digest: MyString
activation_digest: MyString
activated_at: 2019-11-26 15:28:50
activated: false
cv_path: MyString
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