progress if user authenticated
This commit is contained in:
@@ -9,19 +9,16 @@
|
||||
|
||||
<script>
|
||||
import authApi from "../api/authApi";
|
||||
import authService from "../services/authService";
|
||||
|
||||
export default {
|
||||
name: "Welcome",
|
||||
async beforeCreate() {
|
||||
authApi.session = authApi.session.bind(this);
|
||||
authService.progressIfUserAuthenticated = authService.progressIfUserAuthenticated.bind(this);
|
||||
},
|
||||
async created() {
|
||||
try {
|
||||
await authApi.session();
|
||||
await this.$router.replace("/articles");
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
await authService.progressIfUserAuthenticated();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -15,23 +15,20 @@
|
||||
|
||||
export default {
|
||||
name: "Login",
|
||||
beforeCreate() {
|
||||
authApi.session = authApi.session.bind(this);
|
||||
authService.login = authService.login.bind(this);
|
||||
authService.progressIfUserAuthenticated = authService.progressIfUserAuthenticated.bind(this);
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
email: "",
|
||||
password: ""
|
||||
};
|
||||
},
|
||||
beforeCreate() {
|
||||
authApi.session = authApi.session.bind(this);
|
||||
authService.login = authService.login.bind(this);
|
||||
},
|
||||
async created() {
|
||||
try {
|
||||
await authApi.session();
|
||||
await this.$router.replace("/articles");
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
await authService.progressIfUserAuthenticated()
|
||||
},
|
||||
methods: {
|
||||
submit: async function (evt) {
|
||||
|
||||
@@ -27,14 +27,10 @@
|
||||
authApi.session = authApi.session.bind(this);
|
||||
|
||||
authService.register = authService.register.bind(this);
|
||||
authService.progressIfUserAuthenticated = authService.progressIfUserAuthenticated.bind(this);
|
||||
},
|
||||
async created() {
|
||||
try {
|
||||
await authApi.session();
|
||||
await this.$router.replace("/articles");
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
await authService.progressIfUserAuthenticated();
|
||||
},
|
||||
methods: {
|
||||
register: async function (evt) {
|
||||
|
||||
@@ -35,7 +35,12 @@ export default {
|
||||
}
|
||||
},
|
||||
async progressIfUserAuthenticated() {
|
||||
|
||||
try {
|
||||
await authApi.session(commonUtil.getAuthenticationHeaderBearer(this.$cookie.get('accessToken')));
|
||||
await this.$router.replace('/articles');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
},
|
||||
async banishIfUserUnAuthenticated() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user