projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TODO: fix draw logic
[vchess.git]
/
client
/
src
/
components
/
UpsertUser.vue
diff --git
a/client/src/components/UpsertUser.vue
b/client/src/components/UpsertUser.vue
index
46f3bfe
..
6461657
100644
(file)
--- a/
client/src/components/UpsertUser.vue
+++ b/
client/src/components/UpsertUser.vue
@@
-1,11
+1,11
@@
<template lang="pug">
div
input#modalUser.modal(type="checkbox" @change="trySetEnterTime")
<template lang="pug">
div
input#modalUser.modal(type="checkbox" @change="trySetEnterTime")
- div(role="dialog")
+ div(role="dialog"
data-checkbox="modalUser"
)
.card
label.modal-close(for="modalUser")
h3 {{ stage }}
.card
label.modal-close(for="modalUser")
h3 {{ stage }}
- form#userForm(@submit.prevent="onSubmit()")
+ form#userForm(@submit.prevent="onSubmit()"
@keyup.enter="onSubmit"
)
div(v-show="stage!='Login'")
fieldset
label(for="username") Name
div(v-show="stage!='Login'")
fieldset
label(for="username") Name
@@
-26,7
+26,7
@@
div
i.material-icons send
button(v-if="stage!='Update'" @click="toggleStage()")
span {{ stage=="Login" ? "Register" : "Login" }}
i.material-icons send
button(v-if="stage!='Update'" @click="toggleStage()")
span {{ stage=="Login" ? "Register" : "Login" }}
- button(v-else
onClick="location.replace('/logout'
)")
+ button(v-else
@click="doLogout(
)")
span Logout
#dialog(:style="{display: displayInfo}") {{ infoMsg }}
</template>
span Logout
#dialog(:style="{display: displayInfo}") {{ infoMsg }}
</template>
@@
-39,13
+39,27
@@
export default {
name: 'my-upsert-user',
data: function() {
return {
name: 'my-upsert-user',
data: function() {
return {
- user:
Object.assign({}, store.state.user)
,
+ user:
store.state.user
,
nameOrEmail: "", //for login
nameOrEmail: "", //for login
- stage: (store.state.user.id > 0 ? "Update" : "Login"), //TODO?
+ logStage: "Login", //or Register
infoMsg: "",
enterTime: Number.MAX_SAFE_INTEGER, //for a basic anti-bot strategy
};
},
infoMsg: "",
enterTime: Number.MAX_SAFE_INTEGER, //for a basic anti-bot strategy
};
},
+ watch: {
+ nameOrEmail: function(newValue) {
+ if (newValue.indexOf('@') >= 0)
+ {
+ this.user.email = newValue;
+ this.user.name = "";
+ }
+ else
+ {
+ this.user.name = newValue;
+ this.user.email = "";
+ }
+ },
+ },
computed: {
submitMessage: function() {
switch (this.stage)
computed: {
submitMessage: function() {
switch (this.stage)
@@
-61,6
+75,9
@@
export default {
displayInfo: function() {
return (this.infoMsg.length > 0 ? "block" : "none");
},
displayInfo: function() {
return (this.infoMsg.length > 0 ? "block" : "none");
},
+ stage: function() {
+ return this.user.id > 0 ? "Update" : this.logStage;
+ },
},
methods: {
trySetEnterTime: function(event) {
},
methods: {
trySetEnterTime: function(event) {
@@
-69,7
+86,7
@@
export default {
},
toggleStage: function() {
// Loop login <--> register (update is for logged-in users)
},
toggleStage: function() {
// Loop login <--> register (update is for logged-in users)
- this.
stage = (this.s
tage == "Login" ? "Register" : "Login");
+ this.
logStage = (this.logS
tage == "Login" ? "Register" : "Login");
},
ajaxUrl: function() {
switch (this.stage)
},
ajaxUrl: function() {
switch (this.stage)
@@
-137,6
+154,20
@@
export default {
}
);
},
}
);
},
+ doLogout: function() {
+ ajax(
+ "/logout",
+ "GET",
+ () => {
+ this.user.id = 0;
+ this.user.name = "";
+ this.user.email = "";
+ this.user.notify = false;
+ delete localStorage["myid"];
+ delete localStorage["myname"];
+ }
+ );
+ },
},
};
</script>
},
};
</script>