diff --git a/src/App.vue b/src/App.vue
index 7f56d53..d349903 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -36,6 +36,7 @@
+ Sign up
Login
diff --git a/src/components/loginform.vue b/src/components/loginform.vue
index 2a11057..ac33d15 100644
--- a/src/components/loginform.vue
+++ b/src/components/loginform.vue
@@ -1,4 +1,3 @@
-
@@ -25,7 +24,7 @@
+ >{{action}} with {{name}}
@@ -36,8 +35,9 @@
import { apiurl, loginurl, fetch } from "@/util/auth";
export default {
- name: "Loginform",
+ name: "LoginForm",
props: {
+ action: String,
name: String
},
data: function() {
diff --git a/src/components/registerform.vue b/src/components/registerform.vue
new file mode 100644
index 0000000..be694af
--- /dev/null
+++ b/src/components/registerform.vue
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/main.js b/src/main.js
index 0b4adc5..6e8904a 100644
--- a/src/main.js
+++ b/src/main.js
@@ -21,6 +21,7 @@ new Vue({
if (user) {
store.dispatch('setUser', user)
}
+ store.dispatch("setRegisterUser", null)
},
render: h => h(App)
}).$mount("#app");
diff --git a/src/router.js b/src/router.js
index 06cd5cc..d8624a4 100644
--- a/src/router.js
+++ b/src/router.js
@@ -11,6 +11,7 @@ import runs from "./components/runs.vue";
import run from "./components/run.vue";
import task from "./components/task.vue";
import Oauth2 from "./views/Oauth2.vue";
+import Register from "./views/Register.vue";
import Login from "./views/Login.vue";
import Logout from "./views/Logout.vue";
@@ -19,6 +20,11 @@ Vue.use(VueRouter);
export default new VueRouter({
mode: "history",
routes: [
+ {
+ path: "/register",
+ name: "register",
+ component: Register,
+ },
{
path: "/login",
name: "login",
diff --git a/src/store.js b/src/store.js
index 4b362b3..2ab2d39 100644
--- a/src/store.js
+++ b/src/store.js
@@ -5,23 +5,33 @@ Vue.use(Vuex)
const state = {
user: null,
+ registeruser: null
}
const getters = {
user: state => {
return state.user
+ },
+ registeruser: state => {
+ return state.registeruser
}
}
const mutations = {
setUser(state, user) {
state.user = user
+ },
+ setRegisterUser(state, user) {
+ state.registeruser = user
}
}
const actions = {
setUser({ commit }, user) {
commit('setUser', user)
+ },
+ setRegisterUser({ commit }, user) {
+ commit('setRegisterUser', user)
}
}
diff --git a/src/util/auth.js b/src/util/auth.js
index 630be91..f3efb1d 100644
--- a/src/util/auth.js
+++ b/src/util/auth.js
@@ -36,11 +36,19 @@ export function loginurl() {
return new URL(API_URL + "/login");
}
+export function authorizeurl() {
+ return new URL(API_URL + "/authorize");
+}
+
+export function registerurl() {
+ return new URL(API_URL + "/register");
+}
+
export function oauth2callbackurl() {
return new URL(API_URL + "/oauth2/callback");
}
-export function fetch(url, init) {
+export async function fetch(url, init) {
if (init === undefined) {
init = {}
}
@@ -52,11 +60,10 @@ export function fetch(url, init) {
init.headers["Authorization"] = "bearer " + idToken
}
- return window.fetch(url, init).then(res => {
- if (res.status === 401) {
- router.push({ name: "login" })
- } else { return res }
- })
+ let res = await window.fetch(url, init)
+ if (res.status === 401) {
+ router.push({ name: "login" })
+ } else { return res }
}
export function setIdToken(idToken) {
diff --git a/src/views/Login.vue b/src/views/Login.vue
index 58dbaae..2fdd4f5 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -2,7 +2,8 @@