add confirmable

This commit is contained in:
Connor Turland 2017-10-16 18:40:48 -04:00
parent 1b7acd72e1
commit 4f6c93e86e
10 changed files with 40 additions and 32 deletions

View file

@ -7,6 +7,10 @@ module Users
protected
def after_inactive_sign_up_path_for(resource)
sign_in_path
end
def after_update_path_for(resource)
signed_in_root_path(resource)
end

View file

@ -17,7 +17,7 @@ class User < ApplicationRecord
has_many :following, class_name: 'Follow'
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable
devise :database_authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :registerable
serialize :settings, UserPreference
@ -33,6 +33,7 @@ class User < ApplicationRecord
validates :email, presence: true # done by devise
validates :name, uniqueness: true # done by devise
validates :email, uniqueness: true # done by devise
validates_format_of :email, with: /\@uts\.edu\.au/, message: ' must end with @uts.edu.au'
# This method associates the attribute ":image" with a file attachment
has_attached_file :image, styles: {

View file

@ -87,20 +87,6 @@
</div>
<% if current_user %>
<div class="lightboxContent" id="invite">
<h3>SHARE INVITE</h3>
<div class="leaveSpace"></div>
<p>The Metamaps platform is currently in an invite-only beta with the express purpose of creating a high value knowledge ecosystem, a diverse community of contributors and a culture of collaboration and curiosity.</p>
<p>As a valued beta tester, you have the ability to invite your peers, colleagues and collaborators onto the platform.</p>
<p>Below is a personal invite link containing your unique access code, which can be used multiple times.</p>
<div id="joinCodesBox">
<p class="joinCodes"><%= invite_link() %>
<button class="button" onclick="Metamaps.GlobalUI.shareInvite('<%= @invite_link %>');">COPY INVITE LINK!</button>
</div>
</div>
<div class="lightboxContent" id="forkmap">
<%= render :partial => 'shared/forkmap' %>
</div>

View file

@ -3,8 +3,8 @@
# /users/:id/edit
# User edit form
#%>
<% content_for :title, @user.name + "'s Settings | Metamaps" %>
<% content_for :title, @user.name + "'s Settings | Metamaps" %>
<% content_for :mobile_title, "Account Settings" %>
<div id="yield">
<%= form_for @user, url: user_url, :html =>{ :multipart => true, :class => "edit_user centerGreyForm"} do |form| %>
@ -36,9 +36,8 @@
<%= form.label :name, "Name:", class: 'firstFieldText' %>
<%= form.text_field :name %>
</div>
<div>
<%= form.label :email, "Email:", class: 'firstFieldText' %>
<%= form.email_field :email %>
<div class="firstFieldText">
Email: <%= @user.email %>
</div>
<div>
<%= form.label :emails_allowed, class: 'firstFieldText' do %>

View file

@ -6,7 +6,10 @@
<h3>Sign Up</h3>
<div class="fieldText">Only email addresses at the uts.edu.au domain name will be able to register.</div>
<div class="fieldText">
Only email addresses at the uts.edu.au domain name will be able to register.
All users must verify their email address.
</div>
<div><%= f.label :name, "Name:", :class => "firstFieldText" %>
<%= f.text_field :name, :autofocus => true %></div>

View file

@ -116,7 +116,7 @@ Devise.setup do |config|
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed new email is stored in
# unconfirmed email column, and copied to email column on successful confirmation.
config.reconfirmable = true
config.reconfirmable = false
# Defines which key will be used when confirming an account
# config.confirmation_keys = [ :email ]

View file

@ -0,0 +1,20 @@
class AddConfirmableToDevise < ActiveRecord::Migration[5.0]
# Note: You can't use change, as User.update_all will fail in the down migration
def up
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
# add_column :users, :unconfirmed_email, :string # Only if using reconfirmable
add_index :users, :confirmation_token, unique: true
# User.reset_column_information # Need for some types of updates, but not for update_all.
# To avoid a short time window between running the migration and updating all existing
# users as confirmed, do the following
User.all.update_all confirmed_at: DateTime.now
# All existing user accounts should be able to log in after this.
end
def down
remove_columns :users, :confirmation_token, :confirmed_at, :confirmation_sent_at
# remove_columns :users, :unconfirmed_email # Only if using reconfirmable
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170903180840) do
ActiveRecord::Schema.define(version: 20171016214309) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -359,6 +359,10 @@ ActiveRecord::Schema.define(version: 20170903180840) do
t.datetime "image_updated_at"
t.integer "generation"
t.boolean "emails_allowed", default: true
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
end

View file

@ -28,14 +28,6 @@ class AccountMenu extends Component {
<div className="accountIcon"></div>
<a href="/metacodes">Admin</a>
</li>
<li className="accountListItem accountApps">
<div className="accountIcon"></div>
<a href="/oauth/authorized_applications">Apps</a>
</li>
<li className="accountListItem accountInvite" onClick={onInviteClick}>
<div className="accountIcon"></div>
<span>Share Invite</span>
</li>
<li className="accountListItem accountLogout">
<div className="accountIcon"></div>
<a id="Logout" href="/logout">Sign Out</a>

View file

@ -91,7 +91,6 @@ class App extends Component {
openInviteLightbox={openInviteLightbox}
signInPage={pathname === '/login'} />}
<Toast message={toast} />
{!mobile && currentUser && <a className='feedback-icon' target='_blank' href='https://hylo.com/c/metamaps/tag/feedback'></a>}
{children}
</div>
}