mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-18 03:35:17 +00:00
73d1b9d846
<!--- Provide a general summary of your changes in the title above --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Description <!--- Describe your changes in detail --> <!--- Why is this change required? What problem does it solve? --> <!--- If it resolves an open issue, please link to the issue here. For example "Resolves: #1337" --> Corrected `crendentials` to `credentials` in the ["Auth External API" example](https://github.com/nuxt/nuxt.js/tree/dev/examples/auth-jwt). Text-only change. ## Checklist: <!--- Put an `x` in all the boxes that apply. --> <!--- If your change requires a documentation PR, please link it appropriately --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. (PR: #) - [ ] I have added tests to cover my changes (if not applicable, please state why) - [x] All new and existing tests passed.
36 lines
1000 B
Vue
36 lines
1000 B
Vue
<template>
|
|
<div class="container">
|
|
<h1>Sign in to access the secret page</h1>
|
|
<div>
|
|
<label for="email">
|
|
<input id="email" type="email" value="test">
|
|
</label>
|
|
<label for="password">
|
|
<input id="password" type="password" value="test">
|
|
</label>
|
|
<button @click="postLogin">login</button>
|
|
<p>The credentials are not verified for the example purpose.</p>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
const Cookie = process.client ? require('js-cookie') : undefined
|
|
|
|
export default {
|
|
middleware: 'notAuthenticated',
|
|
methods: {
|
|
postLogin() {
|
|
setTimeout(() => { // we simulate the async request with timeout.
|
|
const auth = {
|
|
accessToken: 'someStringGotFromApiServiceWithAjax'
|
|
}
|
|
this.$store.commit('setAuth', auth) // mutating to store for client rendering
|
|
Cookie.set('auth', auth) // saving token in cookie for server rendering
|
|
this.$router.push('/')
|
|
}, 1000)
|
|
}
|
|
}
|
|
}
|
|
</script>
|