Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Added devise. Signup feature is green
Browse files Browse the repository at this point in the history
  • Loading branch information
main24 committed Oct 7, 2012
1 parent c23d750 commit 45ea125
Show file tree
Hide file tree
Showing 35 changed files with 975 additions and 245 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Expand Up @@ -3,13 +3,18 @@ source 'https://rubygems.org'
gem 'rails', '3.2.8'

gem 'sqlite3'
gem 'devise'

group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'jquery-ui-rails'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'

group :development, :test do
gem 'debugger'
Expand Down
22 changes: 22 additions & 0 deletions Gemfile.lock
Expand Up @@ -30,6 +30,7 @@ GEM
multi_json (~> 1.0)
addressable (2.3.2)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.3)
capybara (1.1.2)
mime-types (>= 1.16)
Expand Down Expand Up @@ -70,6 +71,11 @@ GEM
debugger-linecache (1.1.2)
debugger-ruby_core_source (>= 1.1.1)
debugger-ruby_core_source (1.1.3)
devise (2.1.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
Expand All @@ -80,9 +86,16 @@ GEM
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.3)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
jquery-ui-rails (2.0.2)
jquery-rails
railties (>= 3.1.0)
json (1.7.5)
launchy (2.1.2)
addressable (~> 2.3)
libv8 (3.3.10.4)
libwebsocket (0.1.5)
addressable
mail (2.4.4)
Expand All @@ -92,6 +105,7 @@ GEM
mime-types (1.19)
multi_json (1.3.6)
nokogiri (1.5.5)
orm_adapter (0.4.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
Expand Down Expand Up @@ -150,6 +164,8 @@ GEM
steak (2.0.0)
capybara (>= 1.0.0)
rspec-rails (>= 2.5.0)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -159,6 +175,8 @@ GEM
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
warden (1.2.1)
rack (>= 1.0)
xpath (0.1.4)
nokogiri (~> 1.3)

Expand All @@ -172,10 +190,14 @@ DEPENDENCIES
cucumber-rails-training-wheels
database_cleaner
debugger
devise
jquery-rails
jquery-ui-rails
launchy
rails (= 3.2.8)
rspec-rails
sass-rails (~> 3.2.3)
sqlite3
steak
therubyracer
uglifier (>= 1.0.3)
4 changes: 4 additions & 0 deletions app/controllers/home_controller.rb
@@ -0,0 +1,4 @@
class HomeController < ApplicationController
def index
end
end
11 changes: 11 additions & 0 deletions app/models/user.rb
@@ -0,0 +1,11 @@
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
end
25 changes: 25 additions & 0 deletions app/views/devise/registrations/edit.html.erb
@@ -0,0 +1,25 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.label :password, "Пароль" %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, :autocomplete => "off" %></div>

<div><%= f.label :password_confirmation, "Подтверждение" %><br />
<%= f.password_field :password_confirmation %></div>

<div><%= f.label :current_password, "Текущий пароль" %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></div>

<div><%= f.submit "Update" %></div>
<% end %>

<h3>Cancel my account</h3>

<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>

<%= link_to "Back", :back %>
18 changes: 18 additions & 0 deletions app/views/devise/registrations/new.html.erb
@@ -0,0 +1,18 @@
<h2>Sign up</h2>

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.label :password, "Пароль" %><br />
<%= f.password_field :password %></div>

<div><%= f.label :password_confirmation, "Подтверждение" %><br />
<%= f.password_field :password_confirmation %></div>

<div><%= f.submit "Зарегистрироваться" %></div>
<% end %>
<%= render "devise/shared/links" %>
17 changes: 17 additions & 0 deletions app/views/devise/sessions/new.html.erb
@@ -0,0 +1,17 @@
<h2>Sign in</h2>

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.label :password_field, "Пароль" %><br />
<%= f.password_field :password %></div>

<% if devise_mapping.rememberable? -%>
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
<% end -%>

<div><%= f.submit "Sign in" %></div>
<% end %>
<%= render "devise/shared/links" %>
1 change: 1 addition & 0 deletions app/views/home/index.html.erb
@@ -0,0 +1 @@
Hello vrot!
3 changes: 3 additions & 0 deletions app/views/layouts/_notices.html.erb
@@ -0,0 +1,3 @@
<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, id: "flash_#{name}", class: "flash" if msg.is_a?(String) %>
<%- end -%>
7 changes: 6 additions & 1 deletion app/views/layouts/application.html.erb
Expand Up @@ -7,8 +7,13 @@
<%= csrf_meta_tags %>
</head>
<body>
<%= render 'layouts/notices' %>
<ul class="hmenu">
<%= render 'users/shared/signup_links' %>
<%= render 'users/shared/login_links' %>
</ul>

<%= yield %>
<%= yield %>

</body>
</html>
17 changes: 17 additions & 0 deletions app/views/sessions/new.html.erb
@@ -0,0 +1,17 @@
<h2>Sign in</h2>

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.label :password_field, "Пароль" %><br />
<%= f.password_field :password %></div>

<% if devise_mapping.rememberable? -%>
<div><%= f.check_box :remember_me, "Запомнить меня" %> <%= f.label :remember_me %></div>
<% end -%>

<div><%= f.submit "Sign in" %></div>
<% end %>
<%= render "devise/shared/links" %>
12 changes: 12 additions & 0 deletions app/views/users/confirmations/new.html.erb
@@ -0,0 +1,12 @@
<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><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.submit "Resend confirmation instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>
5 changes: 5 additions & 0 deletions app/views/users/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
<p>Welcome <%= @resource.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 => @resource.confirmation_token) %></p>
8 changes: 8 additions & 0 deletions app/views/users/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>

<p>Someone has requested a link to change your password, and you can do this through the link below.</p>

<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_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>
7 changes: 7 additions & 0 deletions app/views/users/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
<p>Hello <%= @resource.email %>!</p>

<p>Your account has been locked due to an excessive amount 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 => @resource.unlock_token) %></p>
16 changes: 16 additions & 0 deletions app/views/users/passwords/edit.html.erb
@@ -0,0 +1,16 @@
<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><%= f.label :password, "New password" %><br />
<%= f.password_field :password %></div>

<div><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation %></div>

<div><%= f.submit "Change my password" %></div>
<% end %>
<%= render "devise/shared/links" %>
12 changes: 12 additions & 0 deletions app/views/users/passwords/new.html.erb
@@ -0,0 +1,12 @@
<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><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.submit "Send me reset password instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>
25 changes: 25 additions & 0 deletions app/views/users/shared/_links.erb
@@ -0,0 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Войти", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Регистрация", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to "Забыл пароль?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Не получал инструкий для подтверждения?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Не получал инструкций для разблокирования?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- 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) %><br />
<% end -%>
<% end -%>
9 changes: 9 additions & 0 deletions app/views/users/shared/_login_links.html.erb
@@ -0,0 +1,9 @@
<% if user_signed_in? %>
<li>
<%= link_to('Выход', destroy_user_session_path, :method => :delete) %>
</li>
<% else %>
<li>
<%= link_to('Войти', new_user_session_path) %>
</li>
<% end %>
9 changes: 9 additions & 0 deletions app/views/users/shared/_signup_links.html.erb
@@ -0,0 +1,9 @@
<% if user_signed_in? %>
<li>
<%= link_to('Изменить профиль', edit_user_registration_path) %>
</li>
<% else %>
<li>
<%= link_to('Регистрация', new_user_registration_path) %>
</li>
<% end %>
12 changes: 12 additions & 0 deletions app/views/users/unlocks/new.html.erb
@@ -0,0 +1,12 @@
<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><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.submit "Resend unlock instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>
2 changes: 1 addition & 1 deletion config/application.rb
Expand Up @@ -31,7 +31,7 @@ class Application < Rails::Application

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.i18n.default_locale = :ru

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
Expand Down

0 comments on commit 45ea125

Please sign in to comment.