mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -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
|
||||
are unable to sign-up. To recieve a link, contact the sites administrator.
|
||||
<v-divider class="mt-3"></v-divider>
|
||||
<v-form>
|
||||
<v-form ref="signUpForm">
|
||||
<v-text-field
|
||||
v-model="user.name"
|
||||
light="light"
|
||||
prepend-icon="mdi-account"
|
||||
validate-on-blur
|
||||
:rules="[existsRule]"
|
||||
label="Display Name"
|
||||
type="email"
|
||||
></v-text-field>
|
||||
|
@ -35,6 +36,7 @@
|
|||
light="light"
|
||||
prepend-icon="mdi-email"
|
||||
validate-on-blur
|
||||
:rules="[existsRule, emailRule]"
|
||||
:label="$t('login.email')"
|
||||
type="email"
|
||||
></v-text-field>
|
||||
|
@ -43,10 +45,10 @@
|
|||
light="light"
|
||||
class="mb-2s"
|
||||
prepend-icon="mdi-lock"
|
||||
validate-on-blur
|
||||
:label="$t('login.password')"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
:append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
|
||||
@click:append="showPassword = !showPassword"
|
||||
:rules="[minRule]"
|
||||
></v-text-field>
|
||||
<v-text-field
|
||||
v-model="user.passwordConfirm"
|
||||
|
@ -56,6 +58,9 @@
|
|||
:label="$t('login.password')"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
:append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
|
||||
:rules="[
|
||||
user.password === user.passwordConfirm || 'Password must match',
|
||||
]"
|
||||
@click:append="showPassword = !showPassword"
|
||||
></v-text-field>
|
||||
</v-form>
|
||||
|
@ -80,7 +85,9 @@
|
|||
|
||||
<script>
|
||||
import api from "@/api";
|
||||
import { validators } from "@/mixins/validators";
|
||||
export default {
|
||||
mixins: [validators],
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
|
@ -126,10 +133,18 @@ export default {
|
|||
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.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 """
|
||||
|
||||
# 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:
|
||||
return {"details": "invalid token"}
|
||||
return SnackResponse.error("Invalid Token")
|
||||
|
||||
# Create User
|
||||
new_user.admin = db_entry.get("admin")
|
||||
new_user.admin = db_entry.admin
|
||||
new_user.password = get_password_hash(new_user.password)
|
||||
data = db.users.create(session, new_user.dict())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue