mirror of
https://github.com/danbulant/ester_os
synced 2026-05-24 12:21:47 +00:00
fix regex & throw invalid username when username won't
This commit is contained in:
parent
99b9d522a9
commit
68ddaf90a8
1 changed files with 3 additions and 2 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
import User from './user';
|
import User from './user';
|
||||||
import NotYetImplemented from '../errors/notYetImplemented';
|
import {NotYetImplemented, InvalidUsername} from '../errors/index';
|
||||||
|
|
||||||
class Login {
|
class Login {
|
||||||
user: User = null;
|
user: User = null;
|
||||||
|
|
||||||
checkName(name: string): boolean{
|
checkName(name: string): boolean{
|
||||||
return /[a-z0-9_-](?:@[a-z0-9_-])/gi.test(name);
|
return /[a-z0-9_-]{1,}(@[a-z0-9_-]{1,})?/gi.test(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchAvatar(name: string): Promise<string>{
|
async fetchAvatar(name: string): Promise<string>{
|
||||||
|
|
@ -13,6 +13,7 @@ class Login {
|
||||||
}
|
}
|
||||||
|
|
||||||
async login(name: string, password: string): Promise<User> {
|
async login(name: string, password: string): Promise<User> {
|
||||||
|
if(!this.checkName(name))throw new InvalidUsername();
|
||||||
throw new NotYetImplemented();
|
throw new NotYetImplemented();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue