-
Notifications
You must be signed in to change notification settings - Fork 2
devise for user authentication and paperclip for avatar #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| class User < ActiveRecord::Base | ||
| # Include default devise modules. Others available are: | ||
| # :confirmable, :lockable, :timeoutable and :omniauthable | ||
| devise :database_authenticatable, :registerable, | ||
| :recoverable, :rememberable, :trackable, :validatable | ||
|
|
||
| validates :name, presence: true | ||
|
|
||
| has_attached_file :avatar, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png" | ||
| validates_attachment :avatar, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] } | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <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="fill-me-in"> | ||
| <%= 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" %> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All these template need to be internationalized.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah 🔢 will do once we agree on using devise instead of twitter |
||
| </div> | ||
| <% end %> | ||
|
|
||
| <%= render "devise/shared/links" %> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <p>Welcome <%= @email %>!</p> | ||
|
|
||
| <p>You can confirm your account email through the link below:</p> | ||
|
|
||
| <p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <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> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <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> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <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="fill-me-in"> | ||
| <%= 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="fill-me-in"> | ||
| <%= 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" %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <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="fill-me-in"> | ||
| <%= 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" %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| | ||
| = devise_error_messages! | ||
| .fill-me-in | ||
| = f.label t("devise.name") | ||
| = f.text_field :name | ||
| .fill-me-in | ||
| = f.label t("devise.email") | ||
| %br/ | ||
| = f.email_field :email | ||
| .fill-me-in | ||
| = f.label t("devise.edit.password") | ||
| = f.password_field :password | ||
| .fill-me-in | ||
| = f.label t("devise.password_confirmation") | ||
| = f.password_field :password_confirmation | ||
| .fill-me-in | ||
| = f.label t("devise.edit.current_password") | ||
| = f.password_field :current_password | ||
| .upload-me | ||
| = f.label t("devise.image") | ||
| = f.file_field :avatar | ||
| .actions | ||
| = f.submit t("devise.update") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| %h2 | ||
| = t("devise.signup") | ||
| = form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| | ||
| = devise_error_messages! | ||
| .fill-me-in | ||
| = f.label t("devise.name") | ||
| = f.text_field :name, autofocus: true | ||
| .fill-me-in | ||
| = f.label t("devise.email") | ||
| = f.email_field :email, autofocus: "off" | ||
| .fill-me-in | ||
| = f.label t("devise.password") | ||
| = f.password_field :password, autocomplete: "off" | ||
| .fill-me-in | ||
| = f.label t("devise.password_confirmation") | ||
| = f.password_field :password_confirmation, autocomplete: "off" | ||
| .upload-me | ||
| = f.label t("devise.image") | ||
| = f.file_field :avatar | ||
| .actions | ||
| = f.submit t("devise.signup") | ||
| = render "devise/shared/links" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| %h2 | ||
| = t("devise.signin") | ||
| = form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| | ||
| = devise_error_messages! | ||
| .fill-me-in | ||
| = f.label t("devise.email") | ||
| = f.email_field :email, autofocus: true | ||
| .fill-me-in | ||
| = f.label t("devise.password") | ||
| = f.password_field :password, autocomplete: "off" | ||
| .actions | ||
| = f.submit t("devise.signin") | ||
| = render "devise/shared/links" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| - if devise_mapping.registerable? && controller_name != 'registrations' | ||
| = link_to t("devise.signup"), new_registration_path(resource_name) | ||
| %br/ | ||
| - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' | ||
| = link_to t("devise.forgot_your_password"), new_password_path(resource_name) | ||
| %br/ | ||
| - if devise_mapping.confirmable? && controller_name != 'confirmations' | ||
| = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) | ||
| %br/ | ||
| - 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/ | ||
| - if devise_mapping.omniauthable? | ||
| - resource_class.omniauth_providers.each do |provider| | ||
| = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <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="fill-me-in"> | ||
| <%= 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" %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| %section#welcome-treatment | ||
| %h1.logo | ||
| %span.keep KEEP | ||
| %br | ||
| %span.delivering DELIVERING | ||
|
|
||
| - if user_signed_in? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this work with our current OAUTH implementation? |
||
| = image_tag current_user.avatar.url(:medium) | ||
| %h2 | ||
| = t("home.welcome" , {name: current_user.name}) | ||
| - else | ||
| %h1.logo | ||
| %span.keep KEEP | ||
| %br | ||
| %span.delivering DELIVERING | ||
| %p | ||
| - mission_link = link_to(t("home.index.description.mission_link"), glossary_path({ anchor: :mission })) | ||
| - deliverable_link = link_to(t("home.index.description.deliverable_link"), glossary_path({ anchor: :deliverable })) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this store the image binary in the DB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. right now it's storing in default directory. we can make it use S3 easily.