Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

fix(default-theme): login page validation causing SSR error #1529

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions packages/default-theme/src/components/SwLogin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,41 @@ import { useUser, useSessionContext } from "@shopware-pwa/composables"
import SwPluginSlot from "sw-plugins/SwPluginSlot.vue"
import SwButton from "@/components/atoms/SwButton.vue"
import SwInput from "@/components/atoms/SwInput.vue"
import { reactive, toRefs } from "@vue/composition-api"

export default {
name: "SwLogin",
components: { SwButton, SwInput, SfAlert, SwPluginSlot },
data() {
return {
email: "",
password: "",
}
},
setup(props, { root }) {
const { login, loading, error: userError } = useUser(root)
const { refreshSessionContext } = useSessionContext(root)

const state = reactive({
email: "",
password: "",
})

const rules = {
email: {
required,
email,
},
password: {
required,
},
}

const $v = useVuelidate(rules, state)

return {
clientLogin: login,
isLoading: loading,
userError,
refreshSessionContext,
$v: useVuelidate(),
$v,
...toRefs(state),
}
},
validations: {
email: {
required,
email,
},
password: {
required,
},
},
methods: {
async invokeLogin() {
this.$v.$touch()
Expand Down