diff --git a/app/assets/javascripts/backbone/plugins/me_announce.js.coffee b/app/assets/javascripts/backbone/plugins/me_announce.js.coffee
index f2f15b66..71b7ae4c 100644
--- a/app/assets/javascripts/backbone/plugins/me_announce.js.coffee
+++ b/app/assets/javascripts/backbone/plugins/me_announce.js.coffee
@@ -5,6 +5,6 @@ class Kandan.Plugins.MeAnnounce
@init: ()->
Kandan.Modifiers.register @options.regex, (message, state) =>
- actor = message.user.first_name || message.user.email
+ actor = message.user.username || message.user.email
message.content = message.content.replace @options.regex, "#{actor} "
return Kandan.Helpers.Activities.buildFromBaseTemplate(message)
diff --git a/app/assets/javascripts/backbone/plugins/user_list.js.coffee b/app/assets/javascripts/backbone/plugins/user_list.js.coffee
index 3599acf5..7b20eb76 100644
--- a/app/assets/javascripts/backbone/plugins/user_list.js.coffee
+++ b/app/assets/javascripts/backbone/plugins/user_list.js.coffee
@@ -17,8 +17,8 @@ class Kandan.Plugins.UserList
for user in Kandan.Data.ActiveUsers.all()
displayName = null
- displayName = "#{user.first_name} #{user.last_name}" if user.first_name?
- displayName ||= user.email # Default to user email address if that's all we have
+ displayName = user.username # Defaults to username
+ displayName ||= user.email # Revert to user email address if that's all we have
$users.append @template({
name: displayName,
diff --git a/app/assets/templates/message.jst.eco b/app/assets/templates/message.jst.eco
index 2de120bd..ac4eb511 100644
--- a/app/assets/templates/message.jst.eco
+++ b/app/assets/templates/message.jst.eco
@@ -5,7 +5,7 @@
- <%= @activity.user.first_name || @activity.user.email %>
+ <%= @activity.user.username || @activity.user.email %>
diff --git a/app/assets/templates/user_notification.jst.eco b/app/assets/templates/user_notification.jst.eco
index 3140629a..44a27288 100644
--- a/app/assets/templates/user_notification.jst.eco
+++ b/app/assets/templates/user_notification.jst.eco
@@ -7,7 +7,7 @@
Kandan bot
- <%= @activity.user.first_name || @activity.user.email %> <%= @activity.action %>ed <%- "#{@activity.content}" if @activity.action == "upload" %>
+ <%= @activity.user.username || @activity.user.email %> <%= @activity.action %>ed <%- "#{@activity.content}" if @activity.action == "upload" %>
diff --git a/app/models/user.rb b/app/models/user.rb
index 6a915ec7..a40df435 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -9,7 +9,7 @@ class User < ActiveRecord::Base
devise devise *Kandan.devise_modules
# Setup accessible (or protected) attributes for your model
- attr_accessible :id, :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :locale, :gravatar_hash
+ attr_accessible :id, :username, :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :locale, :gravatar_hash
def cloudfuji_extra_attributes(extra_attributes)
self.first_name = extra_attributes["first_name"].to_s
diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb
new file mode 100644
index 00000000..b7ae403c
--- /dev/null
+++ b/app/views/devise/confirmations/new.html.erb
@@ -0,0 +1,12 @@
+Resend confirmation instructions
+
+<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.submit "Resend confirmation instructions" %>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
\ No newline at end of file
diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb
new file mode 100644
index 00000000..a6ea8ca1
--- /dev/null
+++ b/app/views/devise/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+Welcome <%= @resource.email %>!
+
+You can confirm your account through the link below:
+
+<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb
new file mode 100644
index 00000000..ae9e888a
--- /dev/null
+++ b/app/views/devise/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+Hello <%= @resource.email %>!
+
+Someone has requested a link to change your password, and you can do this through the link below.
+
+<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
+
+If you didn't request this, please ignore this email.
+Your password won't change until you access the link above and create a new one.
diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb
new file mode 100644
index 00000000..2263c219
--- /dev/null
+++ b/app/views/devise/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+Hello <%= @resource.email %>!
+
+Your account has been locked due to an excessive amount of unsuccessful sign in attempts.
+
+Click the link below to unlock your account:
+
+<%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb
new file mode 100644
index 00000000..e75c9371
--- /dev/null
+++ b/app/views/devise/passwords/edit.html.erb
@@ -0,0 +1,16 @@
+Change your password
+
+<%= 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 %>
+
+ <%= f.label :password, "New password" %>
+ <%= f.password_field :password %>
+
+ <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation %>
+
+ <%= f.submit "Change my password" %>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
\ No newline at end of file
diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb
new file mode 100644
index 00000000..6c21e9fd
--- /dev/null
+++ b/app/views/devise/passwords/new.html.erb
@@ -0,0 +1,12 @@
+Forgot your password?
+
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.submit "Send me reset password instructions" %>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
\ No newline at end of file
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb
new file mode 100644
index 00000000..ff380509
--- /dev/null
+++ b/app/views/devise/registrations/edit.html.erb
@@ -0,0 +1,25 @@
+Edit <%= resource_name.to_s.humanize %>
+
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password %>
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password %>
+
+ <%= f.submit "Update" %>
+<% end %>
+
+Cancel my account
+
+Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.
+
+<%= link_to "Back", :back %>
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb
new file mode 100644
index 00000000..0ffe83b0
--- /dev/null
+++ b/app/views/devise/registrations/new.html.erb
@@ -0,0 +1,21 @@
+Register an Account
+
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.label :username %>
+ <%= f.text_field :username %>
+
+ <%= f.label :password %>
+ <%= f.password_field :password %>
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+
+ <%= f.submit "Register" %>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
new file mode 100644
index 00000000..d16e498f
--- /dev/null
+++ b/app/views/devise/sessions/new.html.erb
@@ -0,0 +1,17 @@
+Sign in
+
+<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
+ <%= f.label :username %>
+ <%= f.text_field :username %>
+
+ <%= f.label :password %>
+ <%= f.password_field :password %>
+
+ <% if devise_mapping.rememberable? -%>
+ <%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%>
+
+ <%= f.submit "Sign in" %>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
\ No newline at end of file
diff --git a/app/views/devise/shared/_links.erb b/app/views/devise/shared/_links.erb
new file mode 100644
index 00000000..eab783a4
--- /dev/null
+++ b/app/views/devise/shared/_links.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+ <%= link_to "Sign in", new_session_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%>
+
+<%- 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) %>
+<% 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) %>
+ <% end -%>
+<% end -%>
\ No newline at end of file
diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb
new file mode 100644
index 00000000..c6cdcfe5
--- /dev/null
+++ b/app/views/devise/unlocks/new.html.erb
@@ -0,0 +1,12 @@
+Resend unlock instructions
+
+<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.submit "Resend unlock instructions" %>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
\ No newline at end of file
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 3f20f358..51bc358d 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -20,6 +20,7 @@
:first_name => current_user.first_name,
:last_name => current_user.last_name,
:email => current_user.email,
+ :username => current_user.username,
:auth_token => current_user.authentication_token,
:gravatar_hash => current_user.gravatar_hash
}
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 8f8ea129..a0bf266a 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -25,7 +25,7 @@
# 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 ]
+ config.authentication_keys = [ :username ]
# 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
@@ -37,12 +37,12 @@
# 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 ]
+ config.case_insensitive_keys = [ :username ]
# 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 ]
+ config.strip_whitespace_keys = [ :username ]
# Tell if authentication through request.params is enabled. True by default.
# config.params_authenticatable = true
diff --git a/db/migrate/20130125210407_add_username_to_users.rb b/db/migrate/20130125210407_add_username_to_users.rb
new file mode 100644
index 00000000..3b71a276
--- /dev/null
+++ b/db/migrate/20130125210407_add_username_to_users.rb
@@ -0,0 +1,5 @@
+class AddUsernameToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :username, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 60686f84..b4b5129a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120404114631) do
+ActiveRecord::Schema.define(:version => 20130125210407) do
create_table "activities", :force => true do |t|
t.text "content"
@@ -70,6 +70,7 @@
t.datetime "updated_at", :null => false
t.text "gravatar_hash"
t.boolean "active", :default => true
+ t.string "username"
end
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true