mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
sign up data validation
This commit is contained in:
parent
11ced89080
commit
495e4d7bec
2 changed files with 22 additions and 7 deletions
|
@ -21,12 +21,13 @@
|
||||||
have a valid invitation link. If you haven't recieved an invitation you
|
have a valid invitation link. If you haven't recieved an invitation you
|
||||||
are unable to sign-up. To recieve a link, contact the sites administrator.
|
are unable to sign-up. To recieve a link, contact the sites administrator.
|
||||||
<v-divider class="mt-3"></v-divider>
|
<v-divider class="mt-3"></v-divider>
|
||||||
<v-form>
|
<v-form ref="signUpForm">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="user.name"
|
v-model="user.name"
|
||||||
light="light"
|
light="light"
|
||||||
prepend-icon="mdi-account"
|
prepend-icon="mdi-account"
|
||||||
validate-on-blur
|
validate-on-blur
|
||||||
|
:rules="[existsRule]"
|
||||||
label="Display Name"
|
label="Display Name"
|
||||||
type="email"
|
type="email"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
light="light"
|
light="light"
|
||||||
prepend-icon="mdi-email"
|
prepend-icon="mdi-email"
|
||||||
validate-on-blur
|
validate-on-blur
|
||||||
|
:rules="[existsRule, emailRule]"
|
||||||
:label="$t('login.email')"
|
:label="$t('login.email')"
|
||||||
type="email"
|
type="email"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
@ -43,10 +45,10 @@
|
||||||
light="light"
|
light="light"
|
||||||
class="mb-2s"
|
class="mb-2s"
|
||||||
prepend-icon="mdi-lock"
|
prepend-icon="mdi-lock"
|
||||||
|
validate-on-blur
|
||||||
:label="$t('login.password')"
|
:label="$t('login.password')"
|
||||||
:type="showPassword ? 'text' : 'password'"
|
:type="showPassword ? 'text' : 'password'"
|
||||||
:append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
|
:rules="[minRule]"
|
||||||
@click:append="showPassword = !showPassword"
|
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="user.passwordConfirm"
|
v-model="user.passwordConfirm"
|
||||||
|
@ -56,6 +58,9 @@
|
||||||
:label="$t('login.password')"
|
:label="$t('login.password')"
|
||||||
:type="showPassword ? 'text' : 'password'"
|
:type="showPassword ? 'text' : 'password'"
|
||||||
:append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
|
:append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
|
||||||
|
:rules="[
|
||||||
|
user.password === user.passwordConfirm || 'Password must match',
|
||||||
|
]"
|
||||||
@click:append="showPassword = !showPassword"
|
@click:append="showPassword = !showPassword"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-form>
|
</v-form>
|
||||||
|
@ -80,7 +85,9 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import api from "@/api";
|
import api from "@/api";
|
||||||
|
import { validators } from "@/mixins/validators";
|
||||||
export default {
|
export default {
|
||||||
|
mixins: [validators],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
|
@ -126,10 +133,18 @@ export default {
|
||||||
admin: false,
|
admin: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
await api.signUps.createUser(this.token, userData);
|
let successUser = false;
|
||||||
|
if (this.$refs.signUpForm.validate()) {
|
||||||
|
let response = await api.signUps.createUser(this.token, userData);
|
||||||
|
successUser = response.snackbar.text.includes("Created");
|
||||||
|
}
|
||||||
|
|
||||||
this.$emit("user-created");
|
this.$emit("user-created");
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
if (successUser) {
|
||||||
|
this.$router.push("/");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,12 +56,12 @@ async def create_user_with_token(
|
||||||
""" Creates a user with a valid sign up token """
|
""" Creates a user with a valid sign up token """
|
||||||
|
|
||||||
# Validate Token
|
# Validate Token
|
||||||
db_entry = db.sign_ups.get(session, token, limit=1)
|
db_entry: SignUpOut = db.sign_ups.get(session, token, limit=1)
|
||||||
if not db_entry:
|
if not db_entry:
|
||||||
return {"details": "invalid token"}
|
return SnackResponse.error("Invalid Token")
|
||||||
|
|
||||||
# Create User
|
# Create User
|
||||||
new_user.admin = db_entry.get("admin")
|
new_user.admin = db_entry.admin
|
||||||
new_user.password = get_password_hash(new_user.password)
|
new_user.password = get_password_hash(new_user.password)
|
||||||
data = db.users.create(session, new_user.dict())
|
data = db.users.create(session, new_user.dict())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue