summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Model
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx/Model')
-rw-r--r--lib/Travelynx/Model/Users.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm
index 8bd60f0..535b938 100644
--- a/lib/Travelynx/Model/Users.pm
+++ b/lib/Travelynx/Model/Users.pm
@@ -201,6 +201,32 @@ sub change_mail_with_token {
return;
}
+sub is_name_invalid {
+ my ( $self, %opt ) = @_;
+ my $db = $opt{db} // $self->{pg}->db;
+ my $name = $opt{name};
+
+ if ( not length($name) ) {
+ return 'user_empty';
+ }
+
+ if ( $name !~ m{ ^ [0-9a-zA-Z_-]+ $ }x ) {
+ return 'user_format';
+ }
+
+ if (
+ $self->user_name_exists(
+ db => $db,
+ name => $name
+ )
+ )
+ {
+ return 'user_collision';
+ }
+
+ return;
+}
+
sub change_name {
my ( $self, %opt ) = @_;
my $db = $opt{db} // $self->{pg}->db;