mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 08:46:41 +01:00
Merge pull request #22 from PFischbeck/authentication
Add Authentication
This commit is contained in:
commit
622a0b0046
3
Gemfile
3
Gemfile
@ -38,6 +38,9 @@ gem 'will_paginate-bootstrap'
|
|||||||
|
|
||||||
gem 'mathjax-rails'
|
gem 'mathjax-rails'
|
||||||
|
|
||||||
|
gem 'devise', '~> 3.4.1'
|
||||||
|
gem 'devise-bootstrap-views'
|
||||||
|
|
||||||
# Use ActiveModel has_secure_password
|
# Use ActiveModel has_secure_password
|
||||||
# gem 'bcrypt', '~> 3.1.7'
|
# gem 'bcrypt', '~> 3.1.7'
|
||||||
|
|
||||||
|
|||||||
16
Gemfile.lock
16
Gemfile.lock
@ -39,6 +39,7 @@ GEM
|
|||||||
arel (6.0.0)
|
arel (6.0.0)
|
||||||
autoprefixer-rails (4.0.2.2)
|
autoprefixer-rails (4.0.2.2)
|
||||||
execjs
|
execjs
|
||||||
|
bcrypt (3.1.10)
|
||||||
bh (1.2.0)
|
bh (1.2.0)
|
||||||
actionpack
|
actionpack
|
||||||
activesupport
|
activesupport
|
||||||
@ -61,6 +62,14 @@ GEM
|
|||||||
term-ansicolor (= 1.2.2)
|
term-ansicolor (= 1.2.2)
|
||||||
thor (= 0.18.1)
|
thor (= 0.18.1)
|
||||||
debug_inspector (0.0.2)
|
debug_inspector (0.0.2)
|
||||||
|
devise (3.4.1)
|
||||||
|
bcrypt (~> 3.0)
|
||||||
|
orm_adapter (~> 0.1)
|
||||||
|
railties (>= 3.2.6, < 5)
|
||||||
|
responders
|
||||||
|
thread_safe (~> 0.1)
|
||||||
|
warden (~> 1.2.3)
|
||||||
|
devise-bootstrap-views (0.0.4)
|
||||||
docile (1.1.5)
|
docile (1.1.5)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.2.2)
|
execjs (2.2.2)
|
||||||
@ -88,6 +97,7 @@ GEM
|
|||||||
multi_json (1.10.1)
|
multi_json (1.10.1)
|
||||||
nokogiri (1.6.5)
|
nokogiri (1.6.5)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
|
orm_adapter (0.5.0)
|
||||||
rack (1.6.0)
|
rack (1.6.0)
|
||||||
rack-test (0.6.2)
|
rack-test (0.6.2)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
@ -118,6 +128,8 @@ GEM
|
|||||||
rake (10.4.2)
|
rake (10.4.2)
|
||||||
rdoc (4.2.0)
|
rdoc (4.2.0)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
|
responders (2.1.0)
|
||||||
|
railties (>= 4.2.0, < 5)
|
||||||
rest-client (1.6.7)
|
rest-client (1.6.7)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
sass (3.4.9)
|
sass (3.4.9)
|
||||||
@ -160,6 +172,8 @@ GEM
|
|||||||
uglifier (2.6.1)
|
uglifier (2.6.1)
|
||||||
execjs (>= 0.3.0)
|
execjs (>= 0.3.0)
|
||||||
json (>= 1.8.0)
|
json (>= 1.8.0)
|
||||||
|
warden (1.2.3)
|
||||||
|
rack (>= 1.0)
|
||||||
web-console (2.0.0)
|
web-console (2.0.0)
|
||||||
activemodel (~> 4.0)
|
activemodel (~> 4.0)
|
||||||
binding_of_caller (>= 0.7.2)
|
binding_of_caller (>= 0.7.2)
|
||||||
@ -178,6 +192,8 @@ DEPENDENCIES
|
|||||||
bootstrap-sass (~> 3.3.1)
|
bootstrap-sass (~> 3.3.1)
|
||||||
coffee-rails (~> 4.1.0)
|
coffee-rails (~> 4.1.0)
|
||||||
coveralls (~> 0.7.2)
|
coveralls (~> 0.7.2)
|
||||||
|
devise (~> 3.4.1)
|
||||||
|
devise-bootstrap-views
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
mathjax-rails
|
mathjax-rails
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
* file per style scope.
|
* file per style scope.
|
||||||
*
|
*
|
||||||
*= require_tree .
|
*= require_tree .
|
||||||
|
*= require devise_bootstrap_views
|
||||||
*= require_self
|
*= require_self
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@ -2,4 +2,5 @@ class ApplicationController < ActionController::Base
|
|||||||
# Prevent CSRF attacks by raising an exception.
|
# Prevent CSRF attacks by raising an exception.
|
||||||
# For APIs, you may want to use :null_session instead.
|
# For APIs, you may want to use :null_session instead.
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
before_action :authenticate_admin!
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
class ProblemsController < ApplicationController
|
class ProblemsController < ApplicationController
|
||||||
|
skip_before_action :authenticate_admin!, only: [:index, :show]
|
||||||
before_action :set_problem, only: [:show]
|
before_action :set_problem, only: [:show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
class TranslationsController < ApplicationController
|
class TranslationsController < ApplicationController
|
||||||
|
skip_before_action :authenticate_admin!, only: [:new, :create]
|
||||||
before_action :set_translation, only: :show
|
before_action :set_translation, only: :show
|
||||||
before_action :set_problem, only: [:new, :create]
|
before_action :set_problem, only: [:new, :create]
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ class TranslationsController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @translation.save
|
if @translation.save
|
||||||
format.html { redirect_to @translation, notice: t('translations.notice.successfully_created') }
|
format.html { redirect_to @translation.problem, notice: t('translations.notice.successfully_created') }
|
||||||
format.json { render :show, status: :created, location: @translation }
|
format.json { render :show, status: :created, location: @translation }
|
||||||
else
|
else
|
||||||
format.html { render :new }
|
format.html { render :new }
|
||||||
|
|||||||
@ -1,2 +1,20 @@
|
|||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
def bootstrap_class_for flash_type
|
||||||
|
{ success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type.to_sym] || flash_type.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def flash_messages(opts = {})
|
||||||
|
capture do
|
||||||
|
flash.each do |msg_type, message|
|
||||||
|
concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} alert-dismissible", role: 'alert') do
|
||||||
|
concat(content_tag(:button, class: 'close', data: { dismiss: 'alert' }) do
|
||||||
|
concat content_tag(:span, '×'.html_safe, 'aria-hidden' => true)
|
||||||
|
concat content_tag(:span, 'Close', class: 'sr-only')
|
||||||
|
end)
|
||||||
|
concat message
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
6
app/models/admin.rb
Normal file
6
app/models/admin.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class Admin < ActiveRecord::Base
|
||||||
|
# Include default devise modules. Others available are:
|
||||||
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
|
devise :database_authenticatable,
|
||||||
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
end
|
||||||
18
app/views/devise/confirmations/new.html.erb
Normal file
18
app/views/devise/confirmations/new.html.erb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<%= bootstrap_devise_error_messages! %>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h4><%= t('.resend_confirmation_instructions', :default => 'Resend confirmation instructions') %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post, role: "form" }) do |f| %>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :email %>
|
||||||
|
<%= f.email_field :email, autofocus: true, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= f.submit t('.resend_confirmation_instructions', :default => 'Resend confirmation instructions'), class: "btn btn-primary" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render "devise/shared/links" %>
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<p><%= t('.greeting', :recipient => @resource.email, :default => "Welcome #{@resource.email}!") %></p>
|
||||||
|
|
||||||
|
<p><%= t('.instruction', :default => "You can confirm your account email through the link below:") %></p>
|
||||||
|
|
||||||
|
<p><%= link_to t('.action', :default => "Confirm my account"),
|
||||||
|
confirmation_url(@resource, :confirmation_token => @token, locale: I18n.locale) %></p>
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
<p><%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %></p>
|
||||||
|
|
||||||
|
<p><%= t('.instruction', :default => "Someone has requested a link to change your password, and you can do this through the link below.") %></p>
|
||||||
|
|
||||||
|
<p><%= link_to t('.action', :default => "Change my password"), edit_password_url(@resource, :reset_password_token => @token, locale: I18n.locale) %></p>
|
||||||
|
|
||||||
|
<p><%= t('.instruction_2', :default => "If you didn't request this, please ignore this email.") %></p>
|
||||||
|
<p><%= t('.instruction_3', :default => "Your password won't change until you access the link above and create a new one.") %></p>
|
||||||
7
app/views/devise/mailer/unlock_instructions.html.erb
Normal file
7
app/views/devise/mailer/unlock_instructions.html.erb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<p><%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %></p>
|
||||||
|
|
||||||
|
<p><%= t('.message', :default => "Your account has been locked due to an excessive amount of unsuccessful sign in attempts.") %></p>
|
||||||
|
|
||||||
|
<p><%= t('.instruction', :default => "Click the link below to unlock your account:") %></p>
|
||||||
|
|
||||||
|
<p><%= link_to t('.action', :default => "Unlock my account"), unlock_url(@resource, :unlock_token => @resource.unlock_token, locale: I18n.locale) %></p>
|
||||||
24
app/views/devise/passwords/edit.html.erb
Normal file
24
app/views/devise/passwords/edit.html.erb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<%= bootstrap_devise_error_messages! %>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h4><%= t('.change_your_password', :default => 'Change your password') %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put, role: "form" }) do |f| %>
|
||||||
|
<%= f.hidden_field :reset_password_token %>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :password, t('.new_password', :default => 'New password') %>
|
||||||
|
<%= f.password_field :password, autofocus: true, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :password_confirmation, t('.confirm_new_password', :default => 'Confirm new password') %>
|
||||||
|
<%= f.password_field :password_confirmation, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= f.submit t('.change_my_password', :default => 'Change my password'), class: "btn btn-primary" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= render "devise/shared/links" %>
|
||||||
17
app/views/devise/passwords/new.html.erb
Normal file
17
app/views/devise/passwords/new.html.erb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<%= bootstrap_devise_error_messages! %>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h4><%= t('.forgot_your_password', :default => 'Forgot your password?') %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, role: "form" }) do |f| %>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :email %>
|
||||||
|
<%= f.email_field :email, autofocus: true, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= f.submit t('.send_me_reset_password_instructions', :default => "Send me reset password instructions"), class: "btn btn-primary" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= render "devise/shared/links" %>
|
||||||
30
app/views/devise/registrations/edit.html.erb
Normal file
30
app/views/devise/registrations/edit.html.erb
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<%= bootstrap_devise_error_messages! %>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h4><%= t('.title', :resource => resource_class.model_name.human , :default => 'Edit #{resource_name.to_s.humanize}') %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :email %>
|
||||||
|
<%= f.email_field :email, autofocus: true, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :password %> <i>(<%= t('.leave_blank_if_you_don_t_want_to_change_it', :default => "leave blank if you don't want to change it") %>)</i><br />
|
||||||
|
<%= f.password_field :password, :autocomplete => "off", class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :password_confirmation %><br />
|
||||||
|
<%= f.password_field :password_confirmation, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :current_password %> <i>(<%= t('.we_need_your_current_password_to_confirm_your_changes', :default => 'we need your current password to confirm your changes') %>)</i>
|
||||||
|
<%= f.password_field :current_password, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<%= f.submit t('.update', :default => "Update"), class: "btn btn-primary" %></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p><%= t('.unhappy', :default => 'Unhappy') %>? <%= link_to t('.cancel_my_account', :default => "Cancel my account"), registration_path(resource_name), :data => { :confirm => t('.are_you_sure', :default => "Are you sure?") }, :method => :delete %>.</p>
|
||||||
|
|
||||||
|
<%= link_to "Back", :back %>
|
||||||
24
app/views/devise/registrations/new.html.erb
Normal file
24
app/views/devise/registrations/new.html.erb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<%= bootstrap_devise_error_messages! %>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h4><%= t('.sign_up', :default => "Sign up") %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { role: "form" }) do |f| %>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :email %>
|
||||||
|
<%= f.email_field :email, autofocus: true, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :password %><br />
|
||||||
|
<%= f.password_field :password, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :password_confirmation %>
|
||||||
|
<%= f.password_field :password_confirmation, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<%= f.submit t('.sign_up', :default => "Sign up"), class: "btn btn-primary" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= render "devise/shared/links" %>
|
||||||
27
app/views/devise/sessions/new.html.erb
Normal file
27
app/views/devise/sessions/new.html.erb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<%= alert_box t('.no_sign_in_required_for_translating'), context: :warning %>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h4><%= t('.sign_in', :default => "Sign in") %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { role: "form" }) do |f| %>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :email %>
|
||||||
|
<%= 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" %>
|
||||||
|
</div>
|
||||||
|
<% if devise_mapping.rememberable? %>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<%= f.check_box :remember_me %> <%= t '.remember_me' %>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<%= f.submit t('.sign_in', :default => "Sign in"), class: "btn btn-primary" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= render "devise/shared/links" %>
|
||||||
25
app/views/devise/shared/_links.erb
Normal file
25
app/views/devise/shared/_links.erb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<%- if controller_name != 'sessions' %>
|
||||||
|
<%= link_to t(".sign_in", :default => "Sign in"), new_session_path(resource_name) %><br />
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||||
|
<%= link_to t(".sign_up", :default => "Sign up"), new_registration_path(resource_name) %><br />
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
||||||
|
<%= link_to t(".forgot_your_password", :default => "Forgot your password?"), new_password_path(resource_name) %><br />
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||||
|
<%= link_to t('.didn_t_receive_confirmation_instructions', :default => "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 t('.didn_t_receive_unlock_instructions', :default => "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 t('.sign_in_with_provider', :provider => provider.to_s.titleize, :default => "Sign in with #{provider.to_s.titleize}"), omniauth_authorize_path(resource_name, provider) %><br />
|
||||||
|
<% end -%>
|
||||||
|
<% end -%>
|
||||||
16
app/views/devise/unlocks/new.html.erb
Normal file
16
app/views/devise/unlocks/new.html.erb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<%= bootstrap_devise_error_messages! %>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h4><%= t('.resend_unlock_instructions', :default => "Resend unlock instructions") %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post, html: { role: "form" } }) do |f| %>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :email %>
|
||||||
|
<%= f.email_field :email, autofocus: true, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
<%= f.submit t('.resend_unlock_instructions', :default => "Resend unlock instructions"), class: "btn btn-primary"%>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= render "devise/shared/links" %>
|
||||||
@ -26,11 +26,21 @@
|
|||||||
<%= horizontal do %>
|
<%= horizontal do %>
|
||||||
<%= nav class: 'navbar-left' do %>
|
<%= nav class: 'navbar-left' do %>
|
||||||
<%= link_to Problem.model_name.human(count: 2), problems_path %>
|
<%= link_to Problem.model_name.human(count: 2), problems_path %>
|
||||||
|
<% if admin_signed_in? %>
|
||||||
<%= link_to Translation.model_name.human(count: 2), translations_path %>
|
<%= link_to Translation.model_name.human(count: 2), translations_path %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= nav class: 'navbar-right' do %>
|
||||||
|
<% if admin_signed_in? %>
|
||||||
|
<%= link_to(t('application.sign_out'), destroy_admin_session_path, method: :delete) %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to(t('application.sign_in'), new_admin_session_path) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<%= flash_messages %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12" role="main">
|
<div class="col-md-12" role="main">
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
<% if notice %>
|
|
||||||
<p id="notice"><%= notice %></p>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1><%= @problem.title %> <small><%= t '.problem_subtitle', id: @problem.id %></small></h1>
|
<h1><%= @problem.title %> <small><%= t '.problem_subtitle', id: @problem.id %></small></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
<% if notice %>
|
|
||||||
<p id="notice"><%= notice %></p>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1><%= @translation.title %> <small><%= t 'problems.show.problem_subtitle', id: @translation.problem_id %></small></h1>
|
<h1><%= @translation.title %> <small><%= t 'problems.show.problem_subtitle', id: @translation.problem_id %></small></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
259
config/initializers/devise.rb
Normal file
259
config/initializers/devise.rb
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||||
|
# Many of these configuration options can be set straight in your model.
|
||||||
|
Devise.setup do |config|
|
||||||
|
# The secret key used by Devise. Devise uses this key to generate
|
||||||
|
# random tokens. Changing this key will render invalid all existing
|
||||||
|
# confirmation, reset password and unlock tokens in the database.
|
||||||
|
# config.secret_key = 'ce69358fd69b66cf4e30a0ed1c1d87bc3ca99550cfb4cad18a706c0b2d21c798c99631524584ee5629c058c6c98aec6e4e217a4ba9f9884e9e59bcb930816e22'
|
||||||
|
|
||||||
|
# ==> Mailer Configuration
|
||||||
|
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||||
|
# note that it will be overwritten if you use your own mailer class
|
||||||
|
# with default "from" parameter.
|
||||||
|
config.mailer_sender = 'no-reply@projekteuler.de'
|
||||||
|
|
||||||
|
# Configure the class responsible to send e-mails.
|
||||||
|
# config.mailer = 'Devise::Mailer'
|
||||||
|
|
||||||
|
# ==> ORM configuration
|
||||||
|
# Load and configure the ORM. Supports :active_record (default) and
|
||||||
|
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
||||||
|
# available as additional gems.
|
||||||
|
require 'devise/orm/active_record'
|
||||||
|
|
||||||
|
# ==> Configuration for any authentication mechanism
|
||||||
|
# Configure which keys are used when authenticating a user. The default is
|
||||||
|
# just :email. You can configure it to use [:username, :subdomain], so for
|
||||||
|
# authenticating a user, both parameters are required. Remember that those
|
||||||
|
# parameters are used only when authenticating and not when retrieving from
|
||||||
|
# session. If you need permissions, you should implement that in a before filter.
|
||||||
|
# You can also supply a hash where the value is a boolean determining whether
|
||||||
|
# or not authentication should be aborted when the value is not present.
|
||||||
|
# config.authentication_keys = [ :email ]
|
||||||
|
|
||||||
|
# Configure parameters from the request object used for authentication. Each entry
|
||||||
|
# given should be a request method and it will automatically be passed to the
|
||||||
|
# find_for_authentication method and considered in your model lookup. For instance,
|
||||||
|
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
||||||
|
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
||||||
|
# config.request_keys = []
|
||||||
|
|
||||||
|
# Configure which authentication keys should be case-insensitive.
|
||||||
|
# These keys will be downcased upon creating or modifying a user and when used
|
||||||
|
# to authenticate or find a user. Default is :email.
|
||||||
|
config.case_insensitive_keys = [ :email ]
|
||||||
|
|
||||||
|
# Configure which authentication keys should have whitespace stripped.
|
||||||
|
# These keys will have whitespace before and after removed upon creating or
|
||||||
|
# modifying a user and when used to authenticate or find a user. Default is :email.
|
||||||
|
config.strip_whitespace_keys = [ :email ]
|
||||||
|
|
||||||
|
# Tell if authentication through request.params is enabled. True by default.
|
||||||
|
# It can be set to an array that will enable params authentication only for the
|
||||||
|
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
||||||
|
# enable it only for database (email + password) authentication.
|
||||||
|
# config.params_authenticatable = true
|
||||||
|
|
||||||
|
# Tell if authentication through HTTP Auth is enabled. False by default.
|
||||||
|
# It can be set to an array that will enable http authentication only for the
|
||||||
|
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
||||||
|
# enable it only for database authentication. The supported strategies are:
|
||||||
|
# :database = Support basic authentication with authentication key + password
|
||||||
|
# config.http_authenticatable = false
|
||||||
|
|
||||||
|
# If 401 status code should be returned for AJAX requests. True by default.
|
||||||
|
# config.http_authenticatable_on_xhr = true
|
||||||
|
|
||||||
|
# The realm used in Http Basic Authentication. 'Application' by default.
|
||||||
|
# config.http_authentication_realm = 'Application'
|
||||||
|
|
||||||
|
# It will change confirmation, password recovery and other workflows
|
||||||
|
# to behave the same regardless if the e-mail provided was right or wrong.
|
||||||
|
# Does not affect registerable.
|
||||||
|
# config.paranoid = true
|
||||||
|
|
||||||
|
# By default Devise will store the user in session. You can skip storage for
|
||||||
|
# particular strategies by setting this option.
|
||||||
|
# Notice that if you are skipping storage for all authentication paths, you
|
||||||
|
# may want to disable generating routes to Devise's sessions controller by
|
||||||
|
# passing skip: :sessions to `devise_for` in your config/routes.rb
|
||||||
|
config.skip_session_storage = [:http_auth]
|
||||||
|
|
||||||
|
# By default, Devise cleans up the CSRF token on authentication to
|
||||||
|
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
||||||
|
# requests for sign in and sign up, you need to get a new CSRF token
|
||||||
|
# from the server. You can disable this option at your own risk.
|
||||||
|
# config.clean_up_csrf_token_on_authentication = true
|
||||||
|
|
||||||
|
# ==> Configuration for :database_authenticatable
|
||||||
|
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
||||||
|
# using other encryptors, it sets how many times you want the password re-encrypted.
|
||||||
|
#
|
||||||
|
# Limiting the stretches to just one in testing will increase the performance of
|
||||||
|
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
||||||
|
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
||||||
|
# encryptor), the cost increases exponentially with the number of stretches (e.g.
|
||||||
|
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
||||||
|
config.stretches = Rails.env.test? ? 1 : 10
|
||||||
|
|
||||||
|
# Setup a pepper to generate the encrypted password.
|
||||||
|
# config.pepper = '8989d40357b9216663584cd1047fd0ea5b1ef21253d5080779f47be43d98f8c04cccfb562cc109975e986e20ad3e5355cdb4a8ebb6768ed64004dbd289acb82b'
|
||||||
|
|
||||||
|
# ==> Configuration for :confirmable
|
||||||
|
# A period that the user is allowed to access the website even without
|
||||||
|
# confirming their account. For instance, if set to 2.days, the user will be
|
||||||
|
# able to access the website for two days without confirming their account,
|
||||||
|
# access will be blocked just in the third day. Default is 0.days, meaning
|
||||||
|
# the user cannot access the website without confirming their account.
|
||||||
|
# config.allow_unconfirmed_access_for = 2.days
|
||||||
|
|
||||||
|
# A period that the user is allowed to confirm their account before their
|
||||||
|
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
||||||
|
# their account within 3 days after the mail was sent, but on the fourth day
|
||||||
|
# their account can't be confirmed with the token any more.
|
||||||
|
# Default is nil, meaning there is no restriction on how long a user can take
|
||||||
|
# before confirming their account.
|
||||||
|
# config.confirm_within = 3.days
|
||||||
|
|
||||||
|
# If true, requires any email changes to be confirmed (exactly the same way as
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Defines which key will be used when confirming an account
|
||||||
|
# config.confirmation_keys = [ :email ]
|
||||||
|
|
||||||
|
# ==> Configuration for :rememberable
|
||||||
|
# The time the user will be remembered without asking for credentials again.
|
||||||
|
# config.remember_for = 2.weeks
|
||||||
|
|
||||||
|
# Invalidates all the remember me tokens when the user signs out.
|
||||||
|
config.expire_all_remember_me_on_sign_out = true
|
||||||
|
|
||||||
|
# If true, extends the user's remember period when remembered via cookie.
|
||||||
|
# config.extend_remember_period = false
|
||||||
|
|
||||||
|
# Options to be passed to the created cookie. For instance, you can set
|
||||||
|
# secure: true in order to force SSL only cookies.
|
||||||
|
# config.rememberable_options = {}
|
||||||
|
|
||||||
|
# ==> Configuration for :validatable
|
||||||
|
# Range for password length.
|
||||||
|
config.password_length = 8..128
|
||||||
|
|
||||||
|
# Email regex used to validate email formats. It simply asserts that
|
||||||
|
# one (and only one) @ exists in the given string. This is mainly
|
||||||
|
# to give user feedback and not to assert the e-mail validity.
|
||||||
|
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
||||||
|
|
||||||
|
# ==> Configuration for :timeoutable
|
||||||
|
# The time you want to timeout the user session without activity. After this
|
||||||
|
# time the user will be asked for credentials again. Default is 30 minutes.
|
||||||
|
# config.timeout_in = 30.minutes
|
||||||
|
|
||||||
|
# If true, expires auth token on session timeout.
|
||||||
|
# config.expire_auth_token_on_timeout = false
|
||||||
|
|
||||||
|
# ==> Configuration for :lockable
|
||||||
|
# Defines which strategy will be used to lock an account.
|
||||||
|
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
||||||
|
# :none = No lock strategy. You should handle locking by yourself.
|
||||||
|
# config.lock_strategy = :failed_attempts
|
||||||
|
|
||||||
|
# Defines which key will be used when locking and unlocking an account
|
||||||
|
# config.unlock_keys = [ :email ]
|
||||||
|
|
||||||
|
# Defines which strategy will be used to unlock an account.
|
||||||
|
# :email = Sends an unlock link to the user email
|
||||||
|
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
||||||
|
# :both = Enables both strategies
|
||||||
|
# :none = No unlock strategy. You should handle unlocking by yourself.
|
||||||
|
# config.unlock_strategy = :both
|
||||||
|
|
||||||
|
# Number of authentication tries before locking an account if lock_strategy
|
||||||
|
# is failed attempts.
|
||||||
|
# config.maximum_attempts = 20
|
||||||
|
|
||||||
|
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
||||||
|
# config.unlock_in = 1.hour
|
||||||
|
|
||||||
|
# Warn on the last attempt before the account is locked.
|
||||||
|
# config.last_attempt_warning = true
|
||||||
|
|
||||||
|
# ==> Configuration for :recoverable
|
||||||
|
#
|
||||||
|
# Defines which key will be used when recovering the password for an account
|
||||||
|
# config.reset_password_keys = [ :email ]
|
||||||
|
|
||||||
|
# Time interval you can reset your password with a reset password key.
|
||||||
|
# Don't put a too small interval or your users won't have the time to
|
||||||
|
# change their passwords.
|
||||||
|
config.reset_password_within = 6.hours
|
||||||
|
|
||||||
|
# ==> Configuration for :encryptable
|
||||||
|
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
||||||
|
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
||||||
|
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
||||||
|
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
||||||
|
# REST_AUTH_SITE_KEY to pepper).
|
||||||
|
#
|
||||||
|
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
||||||
|
# config.encryptor = :sha512
|
||||||
|
|
||||||
|
# ==> Scopes configuration
|
||||||
|
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
||||||
|
# "users/sessions/new". It's turned off by default because it's slower if you
|
||||||
|
# are using only default views.
|
||||||
|
# config.scoped_views = false
|
||||||
|
|
||||||
|
# Configure the default scope given to Warden. By default it's the first
|
||||||
|
# devise role declared in your routes (usually :user).
|
||||||
|
# config.default_scope = :user
|
||||||
|
|
||||||
|
# Set this configuration to false if you want /users/sign_out to sign out
|
||||||
|
# only the current scope. By default, Devise signs out all scopes.
|
||||||
|
# config.sign_out_all_scopes = true
|
||||||
|
|
||||||
|
# ==> Navigation configuration
|
||||||
|
# Lists the formats that should be treated as navigational. Formats like
|
||||||
|
# :html, should redirect to the sign in page when the user does not have
|
||||||
|
# access, but formats like :xml or :json, should return 401.
|
||||||
|
#
|
||||||
|
# If you have any extra navigational formats, like :iphone or :mobile, you
|
||||||
|
# should add them to the navigational formats lists.
|
||||||
|
#
|
||||||
|
# The "*/*" below is required to match Internet Explorer requests.
|
||||||
|
# config.navigational_formats = ['*/*', :html]
|
||||||
|
|
||||||
|
# The default HTTP method used to sign out a resource. Default is :delete.
|
||||||
|
config.sign_out_via = :delete
|
||||||
|
|
||||||
|
# ==> OmniAuth
|
||||||
|
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
||||||
|
# up on your models and hooks.
|
||||||
|
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
||||||
|
|
||||||
|
# ==> Warden configuration
|
||||||
|
# If you want to use other strategies, that are not supported by Devise, or
|
||||||
|
# change the failure app, you can configure them inside the config.warden block.
|
||||||
|
#
|
||||||
|
# config.warden do |manager|
|
||||||
|
# manager.intercept_401 = false
|
||||||
|
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
||||||
|
# end
|
||||||
|
|
||||||
|
# ==> Mountable engine configurations
|
||||||
|
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
||||||
|
# is mountable, there are some extra configurations to be taken into account.
|
||||||
|
# The following options are available, assuming the engine is mounted as:
|
||||||
|
#
|
||||||
|
# mount MyEngine, at: '/my_engine'
|
||||||
|
#
|
||||||
|
# The router that invoked `devise_for`, in the example above, would be:
|
||||||
|
# config.router_name = :my_engine
|
||||||
|
#
|
||||||
|
# When using omniauth, Devise cannot automatically set Omniauth path,
|
||||||
|
# so you need to do it manually. For the users scope, it would be:
|
||||||
|
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
||||||
|
end
|
||||||
60
config/locales/devise.de.yml
Normal file
60
config/locales/devise.de.yml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
||||||
|
|
||||||
|
de:
|
||||||
|
devise:
|
||||||
|
confirmations:
|
||||||
|
confirmed: "Vielen Dank für Ihre Registrierung. Bitte melden Sie sich jetzt an."
|
||||||
|
confirmed_and_signed_in: "Vielen Dank für Ihre Registrierung. Sie sind jetzt angemeldet."
|
||||||
|
send_instructions: "Sie erhalten in wenigen Minuten eine E-Mail, mit der Sie Ihre Registrierung bestätigen können."
|
||||||
|
send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der Sie Ihre Registrierung bestätigen können."
|
||||||
|
failure:
|
||||||
|
already_authenticated: "Sie sind bereits angemeldet."
|
||||||
|
inactive: "Ihr Account ist nicht aktiv."
|
||||||
|
invalid: "Ungültige Anmeldedaten."
|
||||||
|
invalid_token: "Der Anmelde-Token ist ungültig."
|
||||||
|
locked: "Ihr Account ist gesperrt."
|
||||||
|
not_found_in_database: "E-Mail-Adresse oder Passwort ungültig."
|
||||||
|
timeout: "Ihre Sitzung ist abgelaufen, bitte melden Sie sich erneut an."
|
||||||
|
unauthenticated: "Sie müssen sich anmelden oder registrieren, bevor Sie fortfahren können."
|
||||||
|
unconfirmed: "Sie müssen Ihren Account bestätigen, bevor Sie fortfahren können."
|
||||||
|
mailer:
|
||||||
|
confirmation_instructions:
|
||||||
|
subject: "Anleitung zur Bestätigung Ihres Accounts"
|
||||||
|
reset_password_instructions:
|
||||||
|
subject: "Anleitung um Ihr Passwort zurückzusetzen"
|
||||||
|
unlock_instructions:
|
||||||
|
subject: "Anleitung um Ihren Account freizuschalten"
|
||||||
|
omniauth_callbacks:
|
||||||
|
failure: "Sie konnten nicht mit Ihrem %{kind}-Account angemeldet werden, weil '%{reason}'."
|
||||||
|
success: "Sie haben sich erfolgreich mit Ihrem %{kind}-Account angemeldet."
|
||||||
|
passwords:
|
||||||
|
no_token: "Sie können diese Seite nur von dem Link aus einer E-Mail zum Passwort-Zurücksetzen aufrufen. Wenn Sie einen solchen Link aufgerufen haben, stellen Sie bitte sicher, dass Sie die vollständige Adresse aufrufen."
|
||||||
|
send_instructions: "Sie erhalten in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihr Passwort zurücksetzen können."
|
||||||
|
send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihr Passwort zurücksetzen können."
|
||||||
|
updated: "Ihr Passwort wurde geändert. Sie sind jetzt angemeldet."
|
||||||
|
updated_not_active: "Ihr Passwort wurde geändert."
|
||||||
|
registrations:
|
||||||
|
destroyed: "Ihr Account wurde gelöscht."
|
||||||
|
signed_up: "Sie haben sich erfolgreich registriert."
|
||||||
|
signed_up_but_inactive: "Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account inaktiv ist."
|
||||||
|
signed_up_but_locked: "Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account gesperrt ist."
|
||||||
|
signed_up_but_unconfirmed: "Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account noch nicht bestätigt ist. Sie erhalten in Kürze eine E-Mail mit der Anleitung, wie Sie Ihren Account freischalten können."
|
||||||
|
update_needs_confirmation: "Ihre Daten wurden aktualisiert, aber Sie müssen Ihre neue E-Mail-Adresse bestätigen. Sie erhalten in wenigen Minuten eine E-Mail, mit der Sie die Änderung Ihrer E-Mail-Adresse abschliessen können."
|
||||||
|
updated: "Ihre Daten wurden aktualisiert."
|
||||||
|
sessions:
|
||||||
|
signed_in: "Erfolgreich angemeldet."
|
||||||
|
signed_out: "Erfolgreich abgemeldet."
|
||||||
|
unlocks:
|
||||||
|
send_instructions: "Sie erhalten in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihren Account entsperren können."
|
||||||
|
send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihren Account entsperren können."
|
||||||
|
unlocked: "Ihr Account wurde entsperrt. Sie sind jetzt angemeldet."
|
||||||
|
errors:
|
||||||
|
messages:
|
||||||
|
already_confirmed: "wurde bereits bestätigt"
|
||||||
|
confirmation_period_expired: "muss innerhalb %{period} bestätigt werden, bitte fordern Sie einen neuen Link an"
|
||||||
|
expired: "ist abgelaufen, bitte neu anfordern"
|
||||||
|
not_found: "nicht gefunden"
|
||||||
|
not_locked: "ist nicht gesperrt"
|
||||||
|
not_saved:
|
||||||
|
one: "Konnte %{resource} nicht speichern: ein Fehler."
|
||||||
|
other: "Konnte %{resource} nicht speichern: %{count} Fehler."
|
||||||
112
config/locales/devise.views.de.yml
Normal file
112
config/locales/devise.views.de.yml
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
de:
|
||||||
|
devise:
|
||||||
|
confirmations:
|
||||||
|
new:
|
||||||
|
resend_confirmation_instructions: Anleitung zur Bestätigung noch mal schicken
|
||||||
|
confirmed: Ihre Konto wurde erfolgreich bestätigt.
|
||||||
|
send_instructions: Sie erhalten ein wenigen Minuten eine E-Mail mit Anweisungen, wie Sie Ihr Konto bestätigen.
|
||||||
|
send_paranoid_instructions: Falls Ihre E-Mail-Adresse in unserer Datenbank existiert, werden Sie in wenigen Minuten eine E-Mail mit Anweisungen erhalten, wie Sie Ihr Konto bestätigen.
|
||||||
|
failure:
|
||||||
|
already_authenticated: "Sie sind schon angemeldet."
|
||||||
|
inactive: "Ihr Konto ist noch nicht aktiviert."
|
||||||
|
invalid: "Ungültige E-Mail-Adresse oder Passwort."
|
||||||
|
invalid_token: "Ungültiger Authentifikations-Schlüssel."
|
||||||
|
locked: "Ihr Konto ist gesperrt."
|
||||||
|
not_found_in_database: "Ungültige E-Mail-Adresse oder Passwort."
|
||||||
|
timeout: "Ihre Sitzung ist abgelaufen. Bitte melden sich erneut an, um fortzufahren."
|
||||||
|
unauthenticated: "Sie müssen sich anmelden oder registrieren, um fortfahren zu können."
|
||||||
|
unconfirmed: "Sie müssen Ihr Konto bestätigen, um fortfahren zu können."
|
||||||
|
mailer:
|
||||||
|
confirmation_instructions:
|
||||||
|
action: Mein Konto bestätigen
|
||||||
|
greeting: Willkommen %{recipient}!
|
||||||
|
instruction: ! 'Folgen Sie dem untenstehenden Link, um Ihr Konto zu bestätigen:'
|
||||||
|
subject: Anleitung zur Bestätigung Ihres Accounts
|
||||||
|
reset_password_instructions:
|
||||||
|
action: Passwort ändern
|
||||||
|
greeting: Hallo %{recipient}!
|
||||||
|
instruction: Jemand hat einen Link angefordert, um Ihr Passwort zu ändern, und Sie können das durch den unten aufgeführten Link tun.
|
||||||
|
instruction_2: Wenn Sie das nicht angefordert haben, bitte ignorieren Sie diese E-Mail.
|
||||||
|
instruction_3: Das Passwort wird nicht geändert bis Sie den obenstehenden Link abrufen, und ein neues Passwort bestimmen.
|
||||||
|
subject: Anleitung um das Passwort zurückzusetzten
|
||||||
|
unlock_instructions:
|
||||||
|
action: Mein Konto entsperren
|
||||||
|
greeting: Hallo %{recipient}!
|
||||||
|
instruction: ! 'Folgen Sie dem untenstehenden Link, um Ihr Konto zu entsperren:'
|
||||||
|
message: Ihr Konto wurde aufgrund einer großen Anzahl von fehlgeschlagenen Anmeldeversuchen gesperrt.
|
||||||
|
subject: Anleitung um Ihr Konto zu entsperren
|
||||||
|
omniauth_callbacks:
|
||||||
|
failure: "Sie konnten nicht über %{kind} authentifiziert werden, da \"%{reason}\"."
|
||||||
|
success: "Erfolgreich über %{kind} authentifiziert."
|
||||||
|
passwords:
|
||||||
|
new:
|
||||||
|
forgot_your_password: Haben Sie Ihr Passwort vergessen?
|
||||||
|
send_me_reset_password_instructions: Schicken Sie mir die Anleitung, mein Passwort zurückzusetzen
|
||||||
|
edit:
|
||||||
|
change_your_password: Passwort ändern
|
||||||
|
new_password: Neues Passwort
|
||||||
|
confirm_new_password: Neues Passwort bestätigen
|
||||||
|
change_my_password: Ändere mein Passwort
|
||||||
|
no_token: "Sie können diese Seite nicht ohne Link zum Zurücksetzen Ihres Passworts aufrufen. Wenn Sie Ihr Passwort zurücksetzen wollen, gehen Sie sicher, dass Sie die vollständige Adresse benutzt haben, die Sie mit der E-Mail erhalten haben."
|
||||||
|
send_instructions: "Sie werden eine E-Mail mit der Anleitung, wie Sie Ihr Passwort zurücksetzen können, in wenigen Minuten erhalten."
|
||||||
|
send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert, werden Sie in wenigen Minuten eine E-Mail mit einem Link zum Zurücksetzen Ihres Passworts erhalten."
|
||||||
|
updated: Ihr Passwort wurde erfolgreich geändert. Sie sind nun angemeldet.
|
||||||
|
updated_not_active: "Ihr Passwort wurde erfolgreich geändert."
|
||||||
|
registrations:
|
||||||
|
edit:
|
||||||
|
are_you_sure: Sind Sie sicher?
|
||||||
|
cancel_my_account: Konto löschen
|
||||||
|
leave_blank_if_you_don_t_want_to_change_it: freilassen, wenn Sie das nicht ändern wollen
|
||||||
|
title: ! '%{resource} bearbeiten'
|
||||||
|
we_need_your_current_password_to_confirm_your_changes: wir benötigen Ihr aktuelles Passwort, um die Änderung zu bestätigen
|
||||||
|
update: "Aktualisieren"
|
||||||
|
unhappy: "Unglücklich"
|
||||||
|
new:
|
||||||
|
sign_up: Registrieren
|
||||||
|
destroyed: "Auf Wiedersehen! Ihr Konto wurde erfolreich gekündigt. Wir hoffen Sie bald wiederzusehen."
|
||||||
|
signed_up: "Willkommen! Sie haben sich erfolgreich registriert."
|
||||||
|
signed_up_but_inactive: "Sie haben sich erfolgreich registriert. Aber wir konnten Sie nicht anmelden, da Ihr Konto noch nicht aktiviert ist."
|
||||||
|
signed_up_but_locked: "Sie haben sich erfolgreich registriert. Aber wir konnten Sie nicht anmelden, da Ihr Konto gesperrt ist."
|
||||||
|
signed_up_but_unconfirmed: "Eine Nachricht mit einem Aktivierungs-Link wurde an Ihre E-Mail-Adresse geschickt. Bitte öffnen Sie diesen Link, um Ihr Konto zu aktivieren."
|
||||||
|
update_needs_confirmation: "Ihr Konto wurde erfolgreich aktualisiert, aber wir müssen Ihre E-Mail-Adresse verifizieren. Bitte überprüfen Sie Ihre E-Mails und klicken auf den Bestätigungs-Link, um Ihre E-Mail-Adresse abschliessend zu bestätigen."
|
||||||
|
updated: "Ihr Konto wurde erfolgreich aktualisiert."
|
||||||
|
sessions:
|
||||||
|
signed_in: "Erfolgreich angemeldet."
|
||||||
|
signed_out: "Erfolgreich abgemeldet."
|
||||||
|
new:
|
||||||
|
sign_in: Anmelden
|
||||||
|
remember_me: Angemeldet bleiben
|
||||||
|
no_sign_in_required_for_translating: "Für das Vorschlagen von Übersetzungen ist keine Anmeldung notwendig. Die Anmeldung dient lediglich der Verwaltung durch Admins."
|
||||||
|
shared:
|
||||||
|
links:
|
||||||
|
didn_t_receive_confirmation_instructions: Keine Anleitung zur Bestätigung erhalten?
|
||||||
|
didn_t_receive_unlock_instructions: Keine Anleitung zum Entsperren erhalten?
|
||||||
|
forgot_your_password: Passwort vergessen?
|
||||||
|
sign_in: Anmelden
|
||||||
|
sign_in_with_provider: Mit %{provider} anmelden
|
||||||
|
sign_up: Registrieren
|
||||||
|
unlocks:
|
||||||
|
new:
|
||||||
|
resend_unlock_instructions: Anleitung zum Entsperren noch mal schicken
|
||||||
|
send_instructions: "Sie werden eine E-Mail mit der Anleitung, wie Sie Ihr Konto entsperren können, in wenigen Minuten erhalten."
|
||||||
|
send_paranoid_instructions: "Falls Ihr Konto existiert, werden Sie eine E-Mail mit der Anleitung, wie Sie Ihr Konto entsperren können, in wenigen Minuten erhalten."
|
||||||
|
unlocked: "Ihr Konto wurde erfolreich entsperrt. Bitte melden Sie sich an, um fortfahren zu können."
|
||||||
|
errors:
|
||||||
|
messages:
|
||||||
|
already_confirmed: "wurde schon bestätigt - bitte versuchen Sie sich anzumelden"
|
||||||
|
confirmation_period_expired: "muss innerhalb %{period} bestätigt werden - bitte fordern Sie den Link erneut an"
|
||||||
|
expired: "ist ausgelaufen - bitte fordern Sie den Link erneut an"
|
||||||
|
not_found: "nicht gefunden"
|
||||||
|
not_locked: "war nicht gesperrt"
|
||||||
|
not_saved:
|
||||||
|
one: "1 Fehler verhinderte, dass %{resource} gespeichert werden konnte:"
|
||||||
|
other: "%{count} Fehler verhinderten, dass %{resource} gespeichert werden konnte:"
|
||||||
|
activerecord:
|
||||||
|
models:
|
||||||
|
admin: "Admin"
|
||||||
|
attributes:
|
||||||
|
admin:
|
||||||
|
current_sign_in_at: "Angemeldet am"
|
||||||
|
email: "E-Mail"
|
||||||
|
password: "Passwort"
|
||||||
|
last_sign_in_at: "Zuletzt angemeldet am"
|
||||||
6
config/locales/views/application/de.yml
Normal file
6
config/locales/views/application/de.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# ruby encoding: utf-8
|
||||||
|
|
||||||
|
de:
|
||||||
|
application:
|
||||||
|
sign_in: 'Einloggen'
|
||||||
|
sign_out: 'Ausloggen'
|
||||||
@ -1,4 +1,5 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
devise_for :admins, skip: :registrations
|
||||||
resources :problems, only: [:index, :show] do
|
resources :problems, only: [:index, :show] do
|
||||||
resources :translations, only: [:new, :create]
|
resources :translations, only: [:new, :create]
|
||||||
end
|
end
|
||||||
|
|||||||
42
db/migrate/20150131103802_devise_create_admins.rb
Normal file
42
db/migrate/20150131103802_devise_create_admins.rb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
class DeviseCreateAdmins < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table(:admins) 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.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
|
||||||
|
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :admins, :email, unique: true
|
||||||
|
add_index :admins, :reset_password_token, unique: true
|
||||||
|
# add_index :admins, :confirmation_token, unique: true
|
||||||
|
# add_index :admins, :unlock_token, unique: true
|
||||||
|
end
|
||||||
|
end
|
||||||
26
db/schema.rb
26
db/schema.rb
@ -11,9 +11,27 @@
|
|||||||
#
|
#
|
||||||
# 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: 20141214221259) do
|
ActiveRecord::Schema.define(version: 20150131103802) do
|
||||||
|
|
||||||
create_table "problems", force: true do |t|
|
create_table "admins", force: :cascade do |t|
|
||||||
|
t.string "email", default: "", 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 "current_sign_in_ip"
|
||||||
|
t.string "last_sign_in_ip"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "admins", ["email"], name: "index_admins_on_email", unique: true
|
||||||
|
add_index "admins", ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true
|
||||||
|
|
||||||
|
create_table "problems", force: :cascade do |t|
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "translation_id"
|
t.integer "translation_id"
|
||||||
@ -21,8 +39,8 @@ ActiveRecord::Schema.define(version: 20141214221259) do
|
|||||||
|
|
||||||
add_index "problems", ["translation_id"], name: "index_problems_on_translation_id"
|
add_index "problems", ["translation_id"], name: "index_problems_on_translation_id"
|
||||||
|
|
||||||
create_table "translations", force: true do |t|
|
create_table "translations", force: :cascade do |t|
|
||||||
t.string "title"
|
t.string "title", limit: 255
|
||||||
t.text "content"
|
t.text "content"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
Translation.delete_all
|
Translation.delete_all
|
||||||
Problem.delete_all
|
Problem.delete_all
|
||||||
|
Admin.delete_all
|
||||||
|
|
||||||
for i in 1..10 do
|
for i in 1..10 do
|
||||||
translation = Translation.create(
|
translation = Translation.create(
|
||||||
@ -19,3 +20,9 @@ for i in 1..10 do
|
|||||||
end
|
end
|
||||||
|
|
||||||
Problem.create(id: 11)
|
Problem.create(id: 11)
|
||||||
|
|
||||||
|
Admin.create(
|
||||||
|
email: 'admin@example.com',
|
||||||
|
password: 'password',
|
||||||
|
password_confirmation: 'password'
|
||||||
|
)
|
||||||
@ -1,6 +1,8 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class ProblemsControllerTest < ActionController::TestCase
|
class ProblemsControllerTest < ActionController::TestCase
|
||||||
|
include Devise::TestHelpers
|
||||||
|
|
||||||
test "should get index" do
|
test "should get index" do
|
||||||
get :index
|
get :index
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|||||||
@ -1,15 +1,19 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TranslationsControllerTest < ActionController::TestCase
|
class TranslationsControllerTest < ActionController::TestCase
|
||||||
|
include Devise::TestHelpers
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
@translation = translations(:translation_one)
|
@translation = translations(:translation_one)
|
||||||
@update = {
|
@update = {
|
||||||
title: 'New title',
|
title: 'New title',
|
||||||
content: 'This is the new content',
|
content: 'This is the new content',
|
||||||
}
|
}
|
||||||
|
@admin = admins(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get index" do
|
test "should get index" do
|
||||||
|
sign_in @admin
|
||||||
get :index
|
get :index
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil assigns(:translations)
|
assert_not_nil assigns(:translations)
|
||||||
@ -25,10 +29,11 @@ class TranslationsControllerTest < ActionController::TestCase
|
|||||||
post :create, problem_id: 1, translation: @update
|
post :create, problem_id: 1, translation: @update
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to translation_path(assigns(:translation))
|
assert_redirected_to problem_path(id: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should show translation" do
|
test "should show translation" do
|
||||||
|
sign_in @admin
|
||||||
get :show, id: @translation
|
get :show, id: @translation
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|||||||
10
test/fixtures/admins.yml
vendored
Normal file
10
test/fixtures/admins.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
# This model initially had no columns defined. If you add columns to the
|
||||||
|
# model remove the '{}' from the fixture names and add the columns immediately
|
||||||
|
# below each fixture, per the syntax in the comments below
|
||||||
|
#
|
||||||
|
|
||||||
|
admin:
|
||||||
|
email: admin@example.com
|
||||||
|
encrypted_password: <%= Devise.bcrypt(Admin, 'password') %>
|
||||||
13
test/helpers/application_helper_test.rb
Normal file
13
test/helpers/application_helper_test.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ApplicationHelperTest < ActionView::TestCase
|
||||||
|
test "bootstrap classes for flash should return correct values" do
|
||||||
|
assert_equal "alert-danger", bootstrap_class_for(:error)
|
||||||
|
assert_equal "alert-success", bootstrap_class_for(:success)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "bootstrap flash messages should work" do
|
||||||
|
flash[:error] = "Error"
|
||||||
|
assert_equal "<div class=\"alert alert-danger alert-dismissible\" role=\"alert\"><button class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>Error</div>", flash_messages
|
||||||
|
end
|
||||||
|
end
|
||||||
7
test/models/admin_test.rb
Normal file
7
test/models/admin_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class AdminTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue
Block a user