tb_core 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmI2M2I2MjdmZTFkMmFlYWIzMTcwM2U3ZmUxYzVjYWU5ZjkwNTIzMA==
4
+ NmRmYjc1MWEzZWMyZTAzZmVkNTc2ZGFjZDczOTIyN2VhMDU0OTVhNQ==
5
5
  data.tar.gz: !binary |-
6
- Nzg5ODk5Y2YyOTk0ZDAyMjgxNWE3NzFiOWY1Nzg0MzY3ODI1ZTgzZg==
6
+ YTBhYjFhOTIxNzA5ZjNmZTY2M2YzZjBkNTQwYjEwMWM5MTU0NmM3Ng==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OGE0MTBlMzJhNGYxY2I0OWUwYmZkNmYxNjg5NjQ5YmI1M2JjNTJiZTM2NmY1
10
- ODgzNTllZjI1ODJkYTZmZGEzOGU5Njc3YjYwYmY2MDc1NzRkMGQ5ZWE0YjNk
11
- YTk2YjQxMjBlYjUyMzY5MGQ1ZDY0Nzk3NzI5OWEyNGE1MmE1ODM=
9
+ ZTAyNDhiNzNjNWY3NGI0ZGM5N2I4ZTYyZTNkODMxZTI2MTU0NDg1OTgxOTEz
10
+ NDcxOGZkMGYxMDVlMTE1ZjcwMmYzZmI5MjZlZjk1Yjc0ZWM1YmMyZTljYjE4
11
+ MDM4ZTI2ZDJiOTRlYmUyNGI1MDAyOTVkZTE0ZjFkODU5ODEyZTQ=
12
12
  data.tar.gz: !binary |-
13
- MTFhOTEyMTFkZjA2NDAzYTczMDQ1NmQ3NzAyNWE0MDgxNmNhZTlmNzZjZTRk
14
- ZDM0ZmQwM2M1YjQ0OTNhZWJiMDRiNDc1ZTZiNjdkODZjMTdiYThiNjk2NDdh
15
- OWE2NDQzYzQxYTU0MTNkNWM2MGRjZjBkNzY0ZjA4YTQ2YTY0Y2I=
13
+ MjEwNjUyZmNkYTQ5OTMxYjg1ZjE4NDBjODUzZDRmYTA1ZmZjYzFkOGFjYzc5
14
+ ZDg3MjVjNzMyZDFkNjIzNjU5YzdiMDhiNmYyODBiM2RlMWI4ZDQwMzQzOWVl
15
+ ODM2YWUzMjM5ODI5NWQ1MDY0YWExNTU1NzJiMWM3M2FmODdjYTA=
@@ -1,6 +1,6 @@
1
1
  class Admin::ApplicationController < Spud::ApplicationController
2
2
 
3
- before_filter :require_user
3
+ before_filter :require_admin_user
4
4
  before_filter :verify_site_mode
5
5
  add_breadcrumb "Dashboard", :admin_root_path
6
6
  layout 'admin/detail'
@@ -21,7 +21,7 @@ class Admin::ApplicationController < Spud::ApplicationController
21
21
 
22
22
  private
23
23
 
24
- def require_user
24
+ def require_admin_user
25
25
  if current_user.blank?
26
26
  flash[:notice] = "You must be logged in to access the requested page"
27
27
  redirect_to admin_login_path
@@ -1,7 +1,7 @@
1
1
  class Admin::PasswordResetsController < Admin::ApplicationController
2
2
 
3
3
  before_filter :load_user_using_perishable_token, :only => [:show, :update]
4
- skip_before_filter :require_user
4
+ skip_before_filter :require_user, :require_admin_user
5
5
  layout 'admin/login'
6
6
 
7
7
  def index
@@ -11,6 +11,7 @@ class Admin::PasswordResetsController < Admin::ApplicationController
11
11
  def create
12
12
  @user = SpudUser.find_by_email(params[:email])
13
13
  if @user
14
+ @user.reset_perishable_token!
14
15
  CoreMailer.forgot_password_notification(@user, admin_password_reset_url(@user.perishable_token)).deliver
15
16
  flash[:notice] = "Instructions to reset your password have been emailed to you. " +
16
17
  "Please check your email."
@@ -1,7 +1,13 @@
1
1
  class Admin::SettingsController < Admin::ApplicationController
2
2
 
3
- add_breadcrumb "Dashboard", :admin_root_path
4
- add_breadcrumb "Settings", :admin_settings_path
3
+ before_filter :require_user
4
+ skip_before_filter :require_admin_user
5
+
6
+ before_filter do |c|
7
+ if current_user && current_user.has_admin_rights?
8
+ add_breadcrumb "Settings", :admin_settings_path
9
+ end
10
+ end
5
11
 
6
12
  def edit
7
13
 
@@ -10,10 +16,8 @@ class Admin::SettingsController < Admin::ApplicationController
10
16
  def update
11
17
  if @current_user.update_attributes(params[:spud_user].slice :login,:first_name,:last_name,:email,:password,:password_confirmation,:time_zone)
12
18
  flash[:notice] = "User settings saved successfully."
13
- redirect_to admin_root_path
14
- else
15
- render 'edit'
16
19
  end
20
+ render 'edit'
17
21
  end
18
22
 
19
23
  end
@@ -1,6 +1,6 @@
1
1
  class Admin::SetupController < Admin::ApplicationController
2
2
 
3
- skip_before_filter :require_user
3
+ skip_before_filter :require_user, :require_admin_user
4
4
 
5
5
  def new
6
6
  if SpudUser.count != 0
@@ -1,6 +1,6 @@
1
1
  class Admin::UserSessionsController < Admin::ApplicationController
2
2
 
3
- skip_before_filter :require_user
3
+ skip_before_filter :require_admin_user
4
4
  layout 'admin/login'
5
5
 
6
6
  def new
@@ -11,6 +11,7 @@ class PasswordResetsController < ApplicationController
11
11
  def create
12
12
  @user = SpudUser.find_by_email(params[:email])
13
13
  if @user
14
+ @user.reset_perishable_token!
14
15
  CoreMailer.forgot_password_notification(@user, password_reset_url(@user.perishable_token)).deliver
15
16
  flash[:notice] = "Password reset instructions have been sent to your email"
16
17
  redirect_to login_path
@@ -0,0 +1,14 @@
1
+ module TwiceBaked::ApplicationHelper
2
+
3
+ def tb_form_errors(record)
4
+ if record.errors.any?
5
+ content_tag :div, :class => 'form-errors' do
6
+ concat(content_tag :h4, "Please correct the following #{pluralize(record.errors.size, 'error')}:")
7
+ concat(raw "<ul>")
8
+ concat(raw record.errors.full_messages.collect{ |msg| "<li>#{msg}</li>" }.join())
9
+ concat(raw "</ul>")
10
+ end
11
+ end
12
+ end
13
+
14
+ end
@@ -1,10 +1,10 @@
1
1
  <% @login_title = 'Forgot Password' %>
2
- <%= form_tag admin_password_resets_path do %>
3
- <div class="login-form-row">
4
- <%= label_tag :email %>
5
- <%= text_field_tag :email %>
6
- </div>
7
- <div class="login-form-row">
8
- <%= submit_tag "Send Reset Instructions", :class => 'btn' %> or <%= link_to 'Cancel', admin_login_path %>
9
- </div>
10
- <% end %>
2
+ <%= form_tag admin_password_resets_path do %>
3
+ <div class="login-form-row">
4
+ <%= label_tag :email %>
5
+ <%= text_field_tag :email %>
6
+ </div>
7
+ <div class="login-form-row">
8
+ <%= submit_tag "Send Reset Instructions", :class => 'btn' %> or <%= link_to 'Cancel', admin_login_path %>
9
+ </div>
10
+ <% end %>
@@ -8,6 +8,7 @@
8
8
  <%= form_for @current_user, :url => admin_settings_path, :method => :put, :html => {:class => "form-horizontal"} do |f| %>
9
9
  <%= render :partial => "form", :locals => {:f => f} %>
10
10
  <div class="form-actions">
11
- <%= f.submit "Save Settings", :class=>"btn btn-primary"%> or <%=link_to "cancel",request.referer,:class => "btn" %>
11
+ <%= f.submit "Save Settings", :class=>"btn btn-primary"%> or
12
+ <%=link_to "cancel", (@current_user.has_admin_rights? ? admin_root_path : root_path), :class => "btn" %>
12
13
  </div>
13
14
  <% end %>
@@ -9,8 +9,8 @@
9
9
  </head>
10
10
  <body>
11
11
  <div id="header" style="<%=header_style%>">
12
- <%= link_to admin_root_path do %>
13
- <h1><%= Spud::Core.config.site_name %> Admin</h1>
12
+ <%= link_to root_path do %>
13
+ <h1><%= Spud::Core.config.site_name %></h1>
14
14
  <% end %>
15
15
  <% if current_user %>
16
16
  <div id="user_meta">
@@ -1,11 +1,11 @@
1
1
  <h1>Password Reset</h1>
2
2
 
3
- <%= form_tag password_resets_path, :class => 'spud-login-form' do %>
4
- <div class="spud-login-form-row">
3
+ <%= form_tag password_resets_path, :class => 'password-reset-form' do %>
4
+ <div class="form-row">
5
5
  <%= label_tag :email %>
6
- <%= text_field_tag :email %>
6
+ <%= text_field_tag :email, params[:email], :placeholder => 'email' %>
7
7
  </div>
8
- <div class="spud-login-form-row spud-login-form-row-actions">
8
+ <div class="form-row form-row-actions">
9
9
  <%= submit_tag 'Submit', :class => 'btn btn-primary' %> or <%= link_to 'Cancel', login_path %>
10
10
  </div>
11
11
  <% end %>
@@ -1,26 +1,17 @@
1
1
  <div class="login-form">
2
2
  <h1>Password Reset</h1>
3
- <%= form_for @user, url: password_reset_path(:id => @user.perishable_token) do |f| %>
4
- <% if @user.errors.any? %>
5
- <div class="form-errors">
6
- <h2>Please correct the following <%= pluralize(@user.errors.size, 'error') %>:</h2>
7
- <ul>
8
- <% @user.errors.full_messages.each do |msg| %>
9
- <li><%= msg %></li>
10
- <% end %>
11
- </ul>
12
- </div>
13
- <% end %>
14
- <div class="field-group">
3
+ <%= form_for @user, :url => password_reset_path(:id => @user.perishable_token), :html => {:class => 'password-reset-form'} do |f| %>
4
+ <%= tb_form_errors(@user) %>
5
+ <div class="form-row">
15
6
  <%= f.label :password %>
16
- <%= f.password_field :password %>
7
+ <%= f.password_field :password, :placeholder => 'password' %>
17
8
  </div>
18
- <div class="field-group">
19
- <%= f.label :password_confirmation %>
20
- <%= f.password_field :password_confirmation %>
9
+ <div class="form-row">
10
+ <%= f.label :password_confirmation, 'Confirm password' %>
11
+ <%= f.password_field :password_confirmation, 'placeholder' => 'confirm password' %>
21
12
  </div>
22
- <div class="field-group">
23
- <%= f.submit "Reset Password" %>
13
+ <div class="form-row form-row-actions">
14
+ <%= f.submit "Reset Password", :class => 'btn btn-primary' %>
24
15
  </div>
25
16
  <% end %>
26
17
  </div>
@@ -1,25 +1,16 @@
1
- <h1>Login</h1>
1
+ <h1><%= Spud::Core.config.site_name %> Login</h1>
2
2
 
3
- <%= form_for @user_session, :url => login_path, :html => {:class => 'spud-login-form'} do |f| %>
4
- <% if @user_session.errors.any? %>
5
- <div class="form-errors">
6
- <h2>Please correct the following <%= pluralize(@user_session.errors.size, 'error') %>:</h2>
7
- <ul>
8
- <% @user_session.errors.full_messages.each do |msg| %>
9
- <li><%= msg %></li>
10
- <% end %>
11
- </ul>
12
- </div>
13
- <% end %>
3
+ <%= form_for @user_session, :url => login_path, :html => {:class => 'login-form'} do |f| %>
4
+ <%= tb_form_errors(@user_session) %>
14
5
  <div class="form-row">
15
6
  <%= f.label :login %>
16
- <%= f.text_field :login %>
7
+ <%= f.text_field :login, :placeholder => 'username' %>
17
8
  </div>
18
9
  <div class="form-row">
19
10
  <%= f.label :password %>
20
- <%= f.password_field :password %>
11
+ <%= f.password_field :password, :placeholder => 'password' %>
21
12
  </div>
22
13
  <div class="form-row">
23
- <%= f.submit "Login", :class => 'btn btn-primary' %> or <%=link_to "Forgot Password?", password_resets_path %>
14
+ <%= f.submit "Login", :class => 'btn btn-primary' %> <span>or</span> <%=link_to "Forgot Password?", password_resets_path %>
24
15
  </div>
25
16
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ describe Admin::SettingsController do
18
18
  describe :update do
19
19
  it "should redirect to the admin root with a successful update" do
20
20
  put :update, :spud_user => {:first_name => "Mike"}
21
- response.should redirect_to(admin_root_path)
21
+ response.should render_template('edit')
22
22
  end
23
23
 
24
24
  it "should put a message in the flash notice" do