Extract the validation of Username format in own class to avoid

complexity in user model object
This commit is contained in:
Cyril Mougel
2013-02-08 15:52:56 +01:00
committed by Neil Lalonde
parent 3ccfa645a8
commit 84191802df
5 changed files with 81 additions and 35 deletions

View File

@@ -76,7 +76,7 @@ class UsersController < ApplicationController
def check_username
requires_parameter(:username)
if !User.username_valid?(params[:username])
if !UsernameValidator.new(params[:username]).valid_format?
render json: {errors: [I18n.t("user.username.characters")]}
elsif !SiteSetting.call_mothership?
if User.username_available?(params[:username])