mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 09:45:28 +01:00
Check if username exists
This commit is contained in:
parent
964b3bc4c3
commit
a498ef8986
@ -100,6 +100,10 @@ class UsersController:
|
|||||||
def get_all_user_ids() -> t.List[int]:
|
def get_all_user_ids() -> t.List[int]:
|
||||||
return HelperUsers.get_all_user_ids()
|
return HelperUsers.get_all_user_ids()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_all_usernames():
|
||||||
|
return HelperUsers.get_all_usernames()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id_by_name(username):
|
def get_id_by_name(username):
|
||||||
return HelperUsers.get_user_id_by_name(username)
|
return HelperUsers.get_user_id_by_name(username)
|
||||||
|
@ -99,6 +99,14 @@ class HelperUsers:
|
|||||||
query = Users.select().where(Users.username != "system")
|
query = Users.select().where(Users.username != "system")
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_all_usernames():
|
||||||
|
usernames = []
|
||||||
|
query = Users.select().where(Users.username != "system")
|
||||||
|
for user in query:
|
||||||
|
usernames.append(user.username)
|
||||||
|
return usernames
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_all_user_ids() -> t.List[int]:
|
def get_all_user_ids() -> t.List[int]:
|
||||||
return [
|
return [
|
||||||
|
@ -1860,6 +1860,13 @@ class PanelHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
user_id = bleach.clean(self.get_argument("id", None))
|
user_id = bleach.clean(self.get_argument("id", None))
|
||||||
username = bleach.clean(self.get_argument("username", None).lower())
|
username = bleach.clean(self.get_argument("username", None).lower())
|
||||||
|
if (
|
||||||
|
username != self.controller.users.get_user_by_id(user_id)["username"]
|
||||||
|
and username in self.controller.users.get_all_usernames()
|
||||||
|
):
|
||||||
|
self.redirect(
|
||||||
|
"/panel/error?error=Duplicate User: Useranme already exists."
|
||||||
|
)
|
||||||
password0 = bleach.clean(self.get_argument("password0", None))
|
password0 = bleach.clean(self.get_argument("password0", None))
|
||||||
password1 = bleach.clean(self.get_argument("password1", None))
|
password1 = bleach.clean(self.get_argument("password1", None))
|
||||||
email = bleach.clean(self.get_argument("email", "default@example.com"))
|
email = bleach.clean(self.get_argument("email", "default@example.com"))
|
||||||
|
@ -76,28 +76,28 @@
|
|||||||
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'userNameDesc', data['lang'])
|
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'userNameDesc', data['lang'])
|
||||||
}}</small> </label>
|
}}</small> </label>
|
||||||
<input type="text" class="form-control" name="username" id="username" autocomplete="off"
|
<input type="text" class="form-control" name="username" id="username" autocomplete="off"
|
||||||
value="{{ data['user']['username'] }}" placeholder="User Name">
|
data-lpignore="true" value="{{ data['user']['username'] }}" placeholder="User Name">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="password0">{{ translate('userConfig', 'password', data['lang'])
|
<label class="form-label" for="password0">{{ translate('userConfig', 'password', data['lang'])
|
||||||
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang']) }}
|
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang']) }}
|
||||||
</small> </label>
|
</small> </label>
|
||||||
<input type="password" class="form-control" name="password0" id="password0" value=""
|
<input type="password" class="form-control" name="password0" id="password0" value=""
|
||||||
autocomplete="off" placeholder="Password">
|
autocomplete="new-password" data-lpignore="true" placeholder="Password">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="password1">{{ translate('userConfig', 'repeat', data['lang']) }}
|
<label class="form-label" for="password1">{{ translate('userConfig', 'repeat', data['lang']) }}
|
||||||
<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang'])
|
<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang'])
|
||||||
}}</small> </label>
|
}}</small> </label>
|
||||||
<input type="password" class="form-control" name="password1" id="password1" value=""
|
<input type="password" class="form-control" name="password1" id="password1" value=""
|
||||||
autocomplete="off" placeholder="Repeat Password">
|
autocomplete="new-password" data-lpignore="true" placeholder="Repeat Password">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="email">{{ translate('userConfig', 'gravEmail', data['lang'])
|
<label class="form-label" for="email">{{ translate('userConfig', 'gravEmail', data['lang'])
|
||||||
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'gravDesc', data['lang'])
|
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'gravDesc', data['lang'])
|
||||||
}}</small> </label>
|
}}</small> </label>
|
||||||
<input type="email" class="form-control" name="email" id="email" autocomplete="off"
|
<input type="email" class="form-control" name="email" id="email" autocomplete="off"
|
||||||
value="{{ data['user']['email'] }}" placeholder="Gravatar Email">
|
data-lpignore="true" value="{{ data['user']['email'] }}" placeholder="Gravatar Email">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="language">{{ translate('userConfig', 'userLang', data['lang'])
|
<label class="form-label" for="language">{{ translate('userConfig', 'userLang', data['lang'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user