Permit changing my own username's case without an error saying it is already taken

This commit is contained in:
Neil Lalonde
2013-06-28 16:21:46 -04:00
parent b37b6ce664
commit a352b70bfc
4 changed files with 41 additions and 3 deletions

View File

@ -96,6 +96,9 @@ class UsersController < ApplicationController
def check_username
params.require(:username)
# The special case where someone is changing the case of their own username
return render(json: {available: true}) if current_user and params[:username].downcase == current_user.username.downcase
validator = UsernameValidator.new(params[:username])
if !validator.valid_format?
render json: {errors: validator.errors}