Skip to content

Users can now update their username from their settings page #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/usernames_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ class UsernamesController < ApplicationController
skip_before_filter :require_registration

def show
if User.with_username(params[:id]) || User::RESERVED.include?(params[:id].downcase)
# allow validation to pass if it's the user's username that they're trying to validate (for edit username)
if signed_in? && current_user.username.downcase == params[:id].downcase
head :ok
elsif User.with_username(params[:id]) || User::RESERVED.include?(params[:id].downcase)
head :forbidden
else
head :ok
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ def user_update_params
:team_avatar,
:team_banner,
:team_responsibilities,
:title
:title,
:username
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class User < ActiveRecord::Base
include ResqueSupport::Basic
include NetValidators

attr_protected :admin, :username, :id, :github_id, :twitter_id, :linkedin_id, :api_key
attr_protected :admin, :id, :github_id, :twitter_id, :linkedin_id, :api_key

mount_uploader :avatar, AvatarUploader
mount_uploader :banner, BannerUploader
Expand Down
6 changes: 6 additions & 0 deletions app/views/users/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
= content_for :javascript do
= javascript_include_tag 'https://s3.amazonaws.com/cdn.getchute.com/media-chooser.min.js'
= javascript_include_tag 'settings.js'
= javascript_include_tag 'username-validation.js'

- content_for :mixpanel do
= record_view_event('settings')
Expand Down Expand Up @@ -63,6 +64,11 @@
.setting
= form.label :location, "Location: <em>required</em>".html_safe
= form.text_field :location
.setting
= form.label :username, "Username: <em>required</em>".html_safe
= form.text_field :username, 'data-validation' => usernames_path, :maxlength => 15
#username_validation
%p Changing your username will make your previous username available to someone else.
.setting
= form.label :about, "Bio:"
= form.text_area :about
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=content_for :javascript do
=javascript_include_tag 'jquery.ketchup.all.min.js'
=javascript_include_tag 'signup.js'
=javascript_include_tag 'username-validation.js'

-content_for :page_title do
coderwall : level up (step 2 of 2)
Expand Down