confirm-email-sigup-form

parent 45fb6219
Pipeline #1397 canceled with stages
in 0 seconds
......@@ -13,6 +13,7 @@ gem 'friendly_id', '~> 5.4', '>= 5.4.2'
gem 'babosa'
gem 'active_storage_validations'
gem 'mini_magick', '>= 4.9.5'
gem 'devise'
# Use sqlite3 as the database for Active Record
gem 'mysql2', '~> 0.5.3'
# Use Puma as the app server
......
......@@ -67,6 +67,7 @@ GEM
autoprefixer-rails (10.2.5.1)
execjs (> 0)
babosa (1.0.4)
bcrypt (3.1.16)
bindex (0.8.1)
bootsnap (1.7.5)
msgpack (~> 1.0)
......@@ -88,6 +89,12 @@ GEM
chronic (0.10.2)
concurrent-ruby (1.1.9)
crass (1.0.6)
devise (4.8.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
erubi (1.10.0)
execjs (2.8.1)
ffi (1.15.3)
......@@ -129,6 +136,7 @@ GEM
nio4r (2.5.7)
nokogiri (1.11.7-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
popper_js (2.9.2)
public_suffix (4.0.6)
puma (5.3.2)
......@@ -172,6 +180,9 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (2.1.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rubyzip (2.3.1)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
......@@ -210,6 +221,8 @@ GEM
turbolinks-source (5.2.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.1.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
......@@ -243,6 +256,7 @@ DEPENDENCIES
bootstrap (~> 5.0.1)
byebug
capybara (>= 3.26)
devise
friendly_id (~> 5.4, >= 5.4.2)
jbuilder (~> 2.7)
kaminari (~> 1.2, >= 1.2.1)
......
......@@ -157,4 +157,32 @@ footer {
.form-control {
color: $danger;
}
}
.alert-error {
background-color: #f2dede;
border-color: #eed3d7;
color: #b94a48;
text-align: left;
}
.alert-alert {
background-color: #f2dede;
border-color: #eed3d7;
color: #b94a48;
text-align: left;
}
.alert-success {
background-color: #dff0d8;
border-color: #d6e9c6;
color: #468847;
text-align: left;
}
.alert-notice {
background-color: #dff0d8;
border-color: #d6e9c6;
color: #468847;
text-align: left;
}
\ No newline at end of file
class ApplicationController < ActionController::Base
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :cv])
end
def after_sign_up_path_for(resource)
profiles_path(resource)
end
end
class ConfirmationsController < Devise::ConfirmationsController
private
def after_confirmation_path_for(resource_name, resource)
# sign_in(resource) # In case you want to sign in the user
registration_3_path(resource_name)
end
end
class RegistrationsController < Devise::RegistrationsController
# def create
# @user = User.new
# end
# private
# def sign_up_params
# params.require(:user).permit(:email)
# end
# def account_update_params
# params.require(:user).permit(:name, :email, :password, :password_confirmation, :current_password)
# end
end
\ No newline at end of file
class UsersController < ApplicationController
def show
@user = User.new(profile_params)
@user.save
flash[:notice] = "Your user account has been created!"
end
def profile_params
params.require(:user).permit(:name, :email, :password, :password_confirmation, :cv)
end
end
\ No newline at end of file
class User < ApplicationRecord
has_one_attached :cv
has_many :apply_jobs, dependent: :destroy
has_many :favorite_jobs, dependent: :destroy
has_many :history_jobs, dependent: :destroy
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :name, presence: true, length: { maximum: 200 }
validates :email, presence: true, length: { maximum: 200 }, format: { with: VALID_EMAIL_REGEX }
validates :cv, presence: true, content_type: { in: 'application/pdf', message: 'must be a valid image format' },
size: { less_than: 5.megabytes, message: 'should be less than 5MB' }
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
end
......@@ -3,7 +3,7 @@ h2.text-center
| CONFIRM INFORMATION
.col-md-6.offset-md-3.form-apply
= form_with(model: @apply_job, url: done_path, local: true) do |f|
= render 'shared/error_messages'
= render 'shared/error_messages', object: f.object
= f.hidden_field :job_id
= f.label :name
= f.text_field :name, required: true, disabled: true, length: { maximum: 200 },
......
......@@ -3,7 +3,7 @@ h2.text-center.form-title
| APPLY INFORMATION
.col-md-6.offset-md-3.form-apply
= form_with(model: @apply_job, url: confirm_path, local: true) do |f|
= render 'shared/error_messages'
= render 'shared/error_messages', object: f.object
= f.hidden_field :job_id
= f.label :name
= f.text_field :name, required: true, length: { maximum: 200 }, placeholder: "Type name...", class: 'form-control'
......
......@@ -7,7 +7,7 @@ header
li.nav-item.active
= link_to "Login", '#'
li.nav-item
= link_to "Sign up", '#'
= link_to "Register", register_1_path
li.nav-item
= link_to "Favourite", '#'
li.nav-item
......
......@@ -13,6 +13,8 @@ html
body.bg-light
= render 'layouts/header'
.container
/ p.notice= notice
/ p.alert= alert
- flash.each do |key, value|
= content_tag(:div, value, class: "alert alert-#{key}")
= yield
......
- if @apply_job.errors.any?
- if object.errors.any?
#error_explanation
.alert.alert-danger
| The form contains
= pluralize(@apply_job.errors.count, "error")
= pluralize(object.errors.count, "error")
| .
ul
- @apply_job.errors.full_messages.each do |msg|
- object.errors.full_messages.each do |msg|
li
= msg
\ No newline at end of file
h5.p-5.fw-normal.border.bg-white
| Thank you for register our service, an confirmation email with registration link
has been sent to your email. Please check your email within 24 hours.
Please note that the registration link is only valid for 24 hours.
Over that period, you will have to register your email again.
\ No newline at end of file
h2.p-3.text-center
| Register
.row
.col-md-6.offset-md-3.form-apply
= form_for(resource, as: resource_name, url: register_2_path) do |f|
= render 'shared/error_messages', object: resource
.card
.card-body
.field
= f.label :email
br
= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), class: 'form-control'
.actions.p-3.text-center
= f.submit "Confirm your email", class: "btn btn-primary"
p
| Welcome
= @email
| !
p
| You're on your way! Let's confirm your email address. By clicking on the following link, you are confirming your email address and agreeing to VeNJOB's Terms of Service.
p
= link_to 'Confirm my account', registration_3_url(code: @token)
<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| %>
<%= render "users/shared/error_messages", resource: resource %>
<%= 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: "new-password" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "users/shared/links" %>
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "users/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "users/shared/links" %>
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= render "users/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "new-password" %>
<% if @minimum_password_length %>
<br />
<em><%= @minimum_password_length %> characters minimum</em>
<% end %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "current-password" %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% 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 %>
h2.p-3.text-center
| Sign up
.row
.col-md-6.offset-md-3.form-apply
= form_for(resource, as: resource_name, url: my_path) do |f|
= render 'shared/error_messages', object: resource
.card
.card-body
.field
= f.label :name, "Full Name"
br
= f.text_field :name, required: true, length: { maximum: 200 }, class: 'form-control'
.field
= f.label :email
br
= f.email_field :email, required: true, length: { maximum: 200 }, autofocus: true, autocomplete: "email", class: 'form-control'
.field
= f.label :password
- if @minimum_password_length
em
| (
= @minimum_password_length
| characters minimum)
br
= f.password_field :password, required: true, autocomplete: "new-password", class: 'form-control'
.field
= f.label :password_confirmation
br
= f.password_field :password_confirmation, required: true, autocomplete: "new-password", class: 'form-control'
.field
= f.label :cv, "CV"
br
= f.file_field :cv, accept: "application/pdf", size: { less_than: 5.megabytes, message:"should be less than 5MB" }
.actions.p-3.text-center
= f.submit "Sign up", class: "btn btn-primary"
<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, autocomplete: "email" %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "current-password" %>
</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 "users/shared/links" %>
<% if resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= I18n.t("errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
%>
</h2>
<ul>
<% resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%- 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), method: :post %><br />
<% end %>
<% end %>
p
| helloo
=@user.name
\ No newline at end of file
<h2>Resend unlock instructions</h2>
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= render "users/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">
<%= f.submit "Resend unlock instructions" %>
</div>
<% end %>
<%= render "users/shared/links" %>
# Additional translations at https://github.com/heartcombo/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: "Welcome To VeNJOB! Confirm Your Email"
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:"
......@@ -8,4 +8,12 @@ Rails.application.routes.draw do
get 'apply', to: 'apply_jobs#new'
post 'confirm', to: 'apply_jobs#confirm'
post 'done', to: 'apply_jobs#done'
devise_for :users, controllers: { registrations: 'users/registrations', confirmations: 'users/confirmations' }
resources :users, :only => [:show]
post '/my', to: 'users#show'
devise_scope :user do
get 'register/1', to: 'devise/confirmations#new'
post 'register/2', to: 'devise/confirmations#create'
get 'registration/3', to: 'devise/registrations#new'
end
end
\ No newline at end of file
class RemoveCvFromUers < ActiveRecord::Migration[6.1]
def change
remove_column :users, :cv
end
end
class AuthenticatableRegisterableTrackableConfirmableToUser < ActiveRecord::Migration[6.1]
def change
change_table :users do |t|
# Database authenticatable
# t.string :email#, null: false, 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.inet :current_sign_in_ip
t.inet :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
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
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_08_09_075523) do
ActiveRecord::Schema.define(version: 2021_08_18_152915) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name", null: false
......@@ -97,17 +97,6 @@ ActiveRecord::Schema.define(version: 2021_08_09_075523) do
t.index ["user_id"], name: "index_favorite_jobs_on_user_id"
end
create_table "friendly_id_slugs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "slug", null: false
t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50
t.string "scope"
t.datetime "created_at"
t.index ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true, length: { slug: 70, scope: 70 }
t.index ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type", length: { slug: 140 }
t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id"
end
create_table "history_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "job_id", null: false
......@@ -162,9 +151,22 @@ ActiveRecord::Schema.define(version: 2021_08_09_075523) do
create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name"
t.string "email"
t.binary "cv"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
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 "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
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
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
......
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