Some bug fixes

This commit is contained in:
LoveEevee 2020-03-13 08:32:53 +03:00
parent 929471698f
commit ad62ac800c
5 changed files with 86 additions and 41 deletions

2
app.py
View File

@ -205,7 +205,7 @@ def route_api_register():
return api_error('username_in_use')
password = data.get('password', '').encode('utf-8')
if not 8 <= len(password) <= 5000:
if not 6 <= len(password) <= 5000:
return api_error('invalid_password')
salt = bcrypt.gensalt()

View File

@ -256,7 +256,7 @@ class Account{
account.displayName = response.display_name
var loadScores = scores => {
scoreStorage.load(scores)
this.onEnd(false, true)
this.onEnd(false, true, true)
pageEvents.send("login", account.username)
}
if(this.mode === "login"){
@ -267,7 +267,7 @@ class Account{
})
}else{
scoreStorage.save().catch(() => {}).finally(() => {
this.onEnd(false, true)
this.onEnd(false, true, true)
pageEvents.send("login", account.username)
})
}
@ -294,7 +294,7 @@ class Account{
delete account.username
delete account.displayName
var loadScores = scores => {
Cookies.remove("token")
Cookies.remove("session")
scoreStorage.load()
this.onEnd(false, true)
pageEvents.send("logout")
@ -341,7 +341,7 @@ class Account{
account.loggedIn = false
delete account.username
delete account.displayName
Cookies.remove("token")
Cookies.remove("session")
scoreStorage.load()
pageEvents.send("logout")
return Promise.resolve
@ -351,6 +351,8 @@ class Account{
if(!noNameChange && newName !== account.displayName){
promises.push(this.request("account/display_name", {
display_name: newName
}).then(() => {
account.displayName = newName
}))
}
var error = false
@ -368,7 +370,7 @@ class Account{
this.onEnd(false, true)
}, errorFunc).catch(errorFunc)
}
onEnd(event, noSound){
onEnd(event, noSound, noReset){
var touched = false
if(event){
if(event.type === "touchstart"){
@ -381,7 +383,7 @@ class Account{
if(this.locked){
return
}
this.clean()
this.clean(false, noReset)
assets.sounds["se_don"].play()
setTimeout(() => {
new SongSelect(false, false, touched)
@ -391,7 +393,7 @@ class Account{
this.lock(true)
return new Promise((resolve, reject) => {
var request = new XMLHttpRequest()
request.open(obj ? "POST" : "GET", "api/" + url)
request.open("POST", "api/" + url)
pageEvents.load(request).then(() => {
this.lock(false)
if(request.status !== 200){
@ -433,7 +435,7 @@ class Account{
}
}
}
clean(eventsOnly){
clean(eventsOnly, noReset){
if(!eventsOnly){
cancelTouch = true
this.keyboard.clean()
@ -447,8 +449,10 @@ class Account{
for(var i = 0; i < this.inputForms.length; i++){
pageEvents.remove(this.inputForms[i], ["keydown", "keyup", "keypress"])
}
if(!noReset){
this.accountPass.reset()
this.accountDel.reset()
}
delete this.displayname
delete this.accountPassButton
delete this.accountPass
@ -460,7 +464,7 @@ class Account{
delete this.saveButton
delete this.inputForms
}else if(this.mode === "login" || this.mode === "register"){
if(!eventsOnly){
if(!eventsOnly && !noReset){
this.form.reset()
}
pageEvents.remove(this.form, "submit")

View File

@ -9,7 +9,7 @@ class ScoreStorage{
load(strings){
this.scores = {}
if(strings){
this.scoreStrings = strings
this.scoreStrings = this.prepareStrings(strings)
}else if(account.loggedIn){
return
}else{
@ -58,6 +58,13 @@ class ScoreStorage{
}
return output
}
prepareStrings(scores){
var output = {}
for(var k in scores){
output[scores[k].hash] = scores[k].score
}
return output
}
save(localOnly){
for(var hash in this.scores){
this.writeString(hash)

View File

@ -202,7 +202,16 @@
logout: "ログアウト",
back: "もどる",
cancel: "Cancel",
save: "Save"
save: "Save",
displayName: "Displayed Name",
changePassword: "Change Password",
currentNewRepeat: [
"Current Password",
"New Password",
"Repeat New Password"
],
deleteAccount: "Delete Account",
verifyPassword: "Verify password to delete this account"
}
this.browserSupport = {
browserWarning: "サポートされていないブラウザを実行しています (%s)",
@ -645,7 +654,16 @@ function StringsCn(){
logout: "登出",
back: "返回",
cancel: "Cancel",
save: "Save"
save: "Save",
displayName: "Displayed Name",
changePassword: "Change Password",
currentNewRepeat: [
"Current Password",
"New Password",
"Repeat New Password"
],
deleteAccount: "Delete Account",
verifyPassword: "Verify password to delete this account"
}
this.browserSupport = {
browserWarning: "You are running an unsupported browser (%s)",
@ -862,7 +880,16 @@ function StringsTw(){
logout: "登出",
back: "返回",
cancel: "Cancel",
save: "Save"
save: "Save",
displayName: "Displayed Name",
changePassword: "Change Password",
currentNewRepeat: [
"Current Password",
"New Password",
"Repeat New Password"
],
deleteAccount: "Delete Account",
verifyPassword: "Verify password to delete this account"
}
this.browserSupport = {
browserWarning: "You are running an unsupported browser (%s)",
@ -1079,7 +1106,16 @@ function StringsKo(){
logout: "로그 아웃",
back: "돌아간다",
cancel: "Cancel",
save: "Save"
save: "Save",
displayName: "Displayed Name",
changePassword: "Change Password",
currentNewRepeat: [
"Current Password",
"New Password",
"Repeat New Password"
],
deleteAccount: "Delete Account",
verifyPassword: "Verify password to delete this account"
}
this.browserSupport = {
browserWarning: "You are running an unsupported browser (%s)",

View File

@ -394,11 +394,10 @@
h: 130
}
if(this.multiplayer !== 2){
this.nameplateCache.get({
ctx: ctx,
x: 167,
y: 160,
y: this.multiplayer === 2 ? 565 : 160,
w: 219,
h: 53,
id: "1p",
@ -418,7 +417,6 @@
blue: this.multiplayer === 2
})
})
}
ctx.fillStyle = "#000"
ctx.fillRect(
@ -582,7 +580,7 @@
this.nameplateCache.get({
ctx: ctx,
x: 320,
y: this.multiplayer === 2 ? frameTop + 305 : frameTop + 20,
y: this.multiplayer === 2 ? 460 : 20,
w: 273,
h: 66,
id: "1p",