Commit ef114004 by Thanh Hung Pham

Complete feature send email active

parent edb5e7ba
...@@ -17,3 +17,6 @@ ...@@ -17,3 +17,6 @@
/yarn-error.log /yarn-error.log
.byebug_history .byebug_history
# Ignore application configuration
/config/application.yml
...@@ -44,13 +44,15 @@ end ...@@ -44,13 +44,15 @@ end
group :development do group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code. # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2' gem 'listen', '>= 3.0.5', '< 3.2'
gem 'web-console', '>= 3.3.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'better_errors' gem 'better_errors'
gem 'binding_of_caller' gem 'binding_of_caller'
gem 'devise'
gem 'figaro'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
......
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (5.1.1) actioncable (5.1.2)
actionpack (= 5.1.1) actionpack (= 5.1.2)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (~> 0.6.1) websocket-driver (~> 0.6.1)
actionmailer (5.1.1) actionmailer (5.1.2)
actionpack (= 5.1.1) actionpack (= 5.1.2)
actionview (= 5.1.1) actionview (= 5.1.2)
activejob (= 5.1.1) activejob (= 5.1.2)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (5.1.1) actionpack (5.1.2)
actionview (= 5.1.1) actionview (= 5.1.2)
activesupport (= 5.1.1) activesupport (= 5.1.2)
rack (~> 2.0) rack (~> 2.0)
rack-test (~> 0.6.3) rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.1) actionview (5.1.2)
activesupport (= 5.1.1) activesupport (= 5.1.2)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.1) activejob (5.1.2)
activesupport (= 5.1.1) activesupport (= 5.1.2)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (5.1.1) activemodel (5.1.2)
activesupport (= 5.1.1) activesupport (= 5.1.2)
activerecord (5.1.1) activerecord (5.1.2)
activemodel (= 5.1.1) activemodel (= 5.1.2)
activesupport (= 5.1.1) activesupport (= 5.1.2)
arel (~> 8.0) arel (~> 8.0)
activesupport (5.1.1) activesupport (5.1.2)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7) i18n (~> 0.7)
minitest (~> 5.1) minitest (~> 5.1)
...@@ -51,14 +51,14 @@ GEM ...@@ -51,14 +51,14 @@ GEM
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
builder (3.2.3) builder (3.2.3)
byebug (9.0.6) byebug (9.0.6)
capybara (2.14.3) capybara (2.14.4)
addressable addressable
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
xpath (~> 2.0) xpath (~> 2.0)
childprocess (0.7.0) childprocess (0.7.1)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
chronic (0.10.2) chronic (0.10.2)
coderay (1.1.1) coderay (1.1.1)
...@@ -71,10 +71,18 @@ GEM ...@@ -71,10 +71,18 @@ GEM
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
debug_inspector (0.0.3) debug_inspector (0.0.3)
erubi (1.6.0) devise (4.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
responders
warden (~> 1.2.3)
erubi (1.6.1)
erubis (2.7.0) erubis (2.7.0)
execjs (2.7.0) execjs (2.7.0)
ffi (1.9.18) ffi (1.9.18)
figaro (1.1.1)
thor (~> 0.14)
globalid (0.4.0) globalid (0.4.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
i18n (0.8.4) i18n (0.8.4)
...@@ -96,42 +104,46 @@ GEM ...@@ -96,42 +104,46 @@ GEM
mini_portile2 (2.2.0) mini_portile2 (2.2.0)
minitest (5.10.2) minitest (5.10.2)
multi_json (1.12.1) multi_json (1.12.1)
mysql2 (0.4.6) mysql2 (0.4.7)
nio4r (2.1.0) nio4r (2.1.0)
nokogiri (1.8.0) nokogiri (1.8.0)
mini_portile2 (~> 2.2.0) mini_portile2 (~> 2.2.0)
orm_adapter (0.5.0)
public_suffix (2.0.5) public_suffix (2.0.5)
puma (3.9.1) puma (3.9.1)
rack (2.0.3) rack (2.0.3)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rails (5.1.1) rails (5.1.2)
actioncable (= 5.1.1) actioncable (= 5.1.2)
actionmailer (= 5.1.1) actionmailer (= 5.1.2)
actionpack (= 5.1.1) actionpack (= 5.1.2)
actionview (= 5.1.1) actionview (= 5.1.2)
activejob (= 5.1.1) activejob (= 5.1.2)
activemodel (= 5.1.1) activemodel (= 5.1.2)
activerecord (= 5.1.1) activerecord (= 5.1.2)
activesupport (= 5.1.1) activesupport (= 5.1.2)
bundler (>= 1.3.0, < 2.0) bundler (>= 1.3.0, < 2.0)
railties (= 5.1.1) railties (= 5.1.2)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3) rails-html-sanitizer (1.0.3)
loofah (~> 2.0) loofah (~> 2.0)
railties (5.1.1) railties (5.1.2)
actionpack (= 5.1.1) actionpack (= 5.1.2)
activesupport (= 5.1.1) activesupport (= 5.1.2)
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (12.0.0) rake (12.0.0)
rb-fsevent (0.9.8) rb-fsevent (0.10.2)
rb-inotify (0.9.10) rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2) ffi (>= 0.5.0, < 2)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
ruby_dep (1.5.0) ruby_dep (1.5.0)
rubyzip (1.2.1) rubyzip (1.2.1)
sass (3.4.24) sass (3.4.24)
...@@ -166,6 +178,8 @@ GEM ...@@ -166,6 +178,8 @@ GEM
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (3.2.0) uglifier (3.2.0)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
warden (1.2.7)
rack (>= 1.0)
web-console (3.5.1) web-console (3.5.1)
actionview (>= 5.0) actionview (>= 5.0)
activemodel (>= 5.0) activemodel (>= 5.0)
...@@ -189,6 +203,8 @@ DEPENDENCIES ...@@ -189,6 +203,8 @@ DEPENDENCIES
byebug byebug
capybara (~> 2.13) capybara (~> 2.13)
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
devise
figaro
jbuilder (~> 2.5) jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
mysql2 (>= 0.3.18, < 0.5) mysql2 (>= 0.3.18, < 0.5)
......
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
...@@ -14,3 +14,10 @@ ...@@ -14,3 +14,10 @@
*= require_self *= require_self
*= require bootstrap *= require bootstrap
*/ */
.alert-alert {
@extend .alert-warning;
}
.alert-notice {
@extend .alert-info;
}
// Place all the styles related to the Users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
def configure_permitted_parameters
# devise_parameter_sanitizer.fork(:sign_up) << :email
# devise_parameter_sanitizer.fork(:account_update) << :email
end
end end
class UsersController < ApplicationController
def new
@user = User.new
end
end
class User < ApplicationRecord class User < ApplicationRecord
validates :name, presence: true, length: { maximum: 50 } # Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :lockable
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX } validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX }
end end
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<p>You're on your way!</p>
<p>Let's confirm your email address.</p>
<p> By clicking on the following link, you are confirming your email address and agreeing to VeNJOB's Terms of Service. </p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
<p>Hello <%= @email %>!</p>
<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<% end %>
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<%- provide(:title, 'Register') -%>
<div class="well">
<h2>Register</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="form-group">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, class: 'form-control' %>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
</div>
<div class="form-group">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off", class: 'form-control' %>
<span class="help-block">leave blank if you don't want to change it</span>
</div>
<div class="form-group">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :current_password %>
<%= f.password_field :current_password, autocomplete: "off", class: 'form-control' %>
<span class="help-block">we need your current password to confirm your changes</span>
</div>
<%= f.submit "Register", class: 'btn btn-primary' %>
<% end %>
<!--
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %> -->
</div>
<%- provide(:title, 'Register') -%>
<div class="well">
<h2>Register</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="form-group">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.label :password %>
<%= f.password_field :password, autocomplete: 'off', class: 'form-control' %>
<%- if @validatable -%>
<span class="help-block"><%= minimum_password_length %> characters minimum</span>
<%- end -%>
</div>
<div class="form_group">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control' %>
</div>
<%= f.submit "Confirm your email", class: 'btn btn-primary' %>
<% end %>
<!--
<%= render "devise/shared/links" %> -->
</div>
<h2>Log in</h2>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<% if devise_mapping.rememberable? -%>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<div class="actions">
<%= f.submit "Log in" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
<h2>Resend unlock instructions</h2>
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Resend unlock instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
...@@ -3,8 +3,13 @@ ...@@ -3,8 +3,13 @@
<%= link_to image_tag('', alt: 'veNJOB'), root_path, id: 'logo' %> <%= link_to image_tag('', alt: 'veNJOB'), root_path, id: 'logo' %>
<nav> <nav>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li> <%= link_to 'Login', '#' %> </li> <%- if user_signed_in? -%>
<li> <%= link_to 'Register', register_path %> </li> <li> <%= link_to 'My profile', edit_user_registration_path %> </li>
<li> <%= link_to 'Log out', destroy_user_session_path, method: :delete %> </li>
<%- else -%>
<li> <%= link_to 'Login', new_user_session_path %> </li>
<li> <%= link_to 'Register', new_user_registration_path %> </li>
<%- end -%>
<li> <%= link_to 'Favorite', '#' %> </li> <li> <%= link_to 'Favorite', '#' %> </li>
<li> <%= link_to 'History', '#' %> </li> <li> <%= link_to 'History', '#' %> </li>
</ul> </ul>
......
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
<body> <body>
<%= render 'layouts/header' %> <%= render 'layouts/header' %>
<div class="container"> <div class="container">
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>">
<%= value %>
</div>
<% end %>
<%= yield %> <%= yield %>
<%= render 'layouts/footer' %> <%= render 'layouts/footer' %>
</div> </div>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<%= job.salary %> <%= job.salary %>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<%= job.city.name %> <%= job.city.name unless job.city.nil? %>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<%= truncate(job.description, length: 250) %> <%= truncate(job.description, length: 250) %>
......
<%- provide(:title, 'Register') -%>
<h1>Register</h1>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(@user) do |f| %>
<%= f.label :email %>
<%= f.email_field :email %>
<%= f.submit 'Confirm your email', class: 'btn btn-primary' %>
<%- end -%>
</div>
</div>
...@@ -27,7 +27,20 @@ Rails.application.configure do ...@@ -27,7 +27,20 @@ Rails.application.configure do
end end
# Don't care if the mailer can't send. # Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.default charset: 'utf-8'
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'zigexn.vn',
user_name: 'hungpt@zigexn.vn',
password: 'hung@1234567pham@',
authentication: 'plain',
enable_starttls_auto: true
}
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
......
# 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 confirm link to confirm your new email address."
updated: "Your account has been updated successfully."
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
root 'static_pages#home' root 'static_pages#home'
get 'static_pages/home' get 'static_pages/home'
......
class CreateUsers < ActiveRecord::Migration[5.1] class CreateUsers < ActiveRecord::Migration[5.1]
def change def change
create_table :users do |t| create_table :users do |t|
t.string :email
t.string :password t.string :password
t.string :fullname t.string :fullname
t.string :reset_digest
t.datetime :reset_sent_at
t.string :activation_digest
t.boolean :activated
t.datetime :activated_at
t.boolean :admin t.boolean :admin
t.string :cv_name t.string :cv_name
......
class AddDeviseToUsers < ActiveRecord::Migration[5.1]
def self.up
change_table :users do |t|
## Database authenticatable
t.string :email, default: ''
t.string :encrypted_password, null: false, default: ''
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_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.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
# Uncomment below if timestamps were not included in your original model.
# t.timestamps null: false
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
def self.down
# By default, we don't want to make any assumption about how to roll back a migration when your
# model already existed. Please edit below which fields you would like to remove in this migration.
raise ActiveRecord::IrreversibleMigration
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170628020034) do ActiveRecord::Schema.define(version: 20170705034837) do
create_table "applies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "applies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.bigint "user_id" t.bigint "user_id"
...@@ -121,18 +121,33 @@ ActiveRecord::Schema.define(version: 20170628020034) do ...@@ -121,18 +121,33 @@ ActiveRecord::Schema.define(version: 20170628020034) do
end end
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "email"
t.string "password" t.string "password"
t.string "fullname" t.string "fullname"
t.string "reset_digest"
t.datetime "reset_sent_at"
t.string "activation_digest"
t.boolean "activated"
t.datetime "activated_at"
t.boolean "admin" t.boolean "admin"
t.string "cv_name" t.string "cv_name"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "email", default: ""
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
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"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.integer "failed_attempts", default: 0, null: false
t.string "unlock_token"
t.datetime "locked_at"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
end end
end end
require 'test_helper'
class UsersControllerTest < ActionDispatch::IntegrationTest
test "should get new" do
get users_new_url
assert_response :success
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