From 75f9dc98499adfc399069bcec39108ec3ecb1ce4 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:31:32 -0400 Subject: [PATCH 01/45] [U] Remove testing error text --- src/components/login/login.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index 12a244f..d9bda7f 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -13,7 +13,7 @@ export default class Login extends Vue public password: any = ''; public loading: boolean = false; - public error: String = 'asdf'; + public error: String = ''; /** * On click, sends username and password to the server. From 8860c88b1ae492eda420e0719587b565db68213f Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 09:09:50 -0400 Subject: [PATCH 02/45] [F] Fix HTTP GET can't have body --- src/components/login/login.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index d9bda7f..a4ec4fc 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -25,7 +25,7 @@ export default class Login extends Vue // Fetch request TODO: Add username and password when the https server is ready. fetch(`${Constants.API_URL}/api/login`, - {body: JSON.stringify({username: this.username, password: this.password})}) + {method: 'POST', body: JSON.stringify({username: this.username, password: this.password})}) .then(res => { // Get response body text From 38089c74b5323b87520ad57021f9cda934cea54e Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 09:13:11 -0400 Subject: [PATCH 03/45] [F] Fix duplicate "/api/" in path --- src/components/login/login.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index a4ec4fc..8422194 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -24,7 +24,7 @@ export default class Login extends Vue this.loading = true; // Fetch request TODO: Add username and password when the https server is ready. - fetch(`${Constants.API_URL}/api/login`, + fetch(`${Constants.API_URL}/login`, {method: 'POST', body: JSON.stringify({username: this.username, password: this.password})}) .then(res => { From 2338e4f6afd9f7ba63b957765f091a75ec065a6a Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 09:14:13 -0400 Subject: [PATCH 04/45] [+] Show error message on error --- src/components/login/login.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index 8422194..0879d78 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -42,6 +42,9 @@ export default class Login extends Vue } else { + // Show error message + this.error = response.token; + // Allow the user to retry this.loading = false; } From 3ce21623d8b69466b5c4fc95efe9bfae626033c1 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 09:21:29 -0400 Subject: [PATCH 05/45] [+] Import vue-cookies --- package-lock.json | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) diff --git a/package-lock.json b/package-lock.json index a3d4fc7..735f25d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10848,6 +10848,11 @@ "resolved": "https://registry.npm.taobao.org/vue-class-component/download/vue-class-component-7.1.0.tgz", "integrity": "sha1-sz78sQ4XI21oT3Cx6W8ZRux5Poc=" }, + "vue-cookies": { + "version": "1.5.13", + "resolved": "https://registry.npmjs.org/vue-cookies/-/vue-cookies-1.5.13.tgz", + "integrity": "sha512-8pjpXnvbNWx1Lft0t3MJnW+ylv0Wa2Tb6Ch617u/pQah3+SfXUZZdkh3EL3bSpe/Sw2Wdw3+DhycgQsKANSxXg==" + }, "vue-hot-reload-api": { "version": "2.3.3", "resolved": "https://registry.npm.taobao.org/vue-hot-reload-api/download/vue-hot-reload-api-2.3.3.tgz", diff --git a/package.json b/package.json index e956b28..2117965 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "v-charts": "^1.19.0", "vue": "^2.6.10", "vue-class-component": "^7.0.2", + "vue-cookies": "^1.5.13", "vue-property-decorator": "^8.1.0" }, "devDependencies": { From 4782870d94a9de41cd517d67c63e85b1f94ae793 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 09:21:57 -0400 Subject: [PATCH 06/45] [+] Add vue-cookies to Vue.use() --- src/main.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.ts b/src/main.ts index 2f5c043..f486226 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,7 @@ import ElementUI from 'element-ui'; const VCharts = require('v-charts'); import App from './components/app/app.vue'; +import VueCookies from 'vue-cookies'; Vue.config.productionTip = false; @@ -12,6 +13,9 @@ Vue.use(ElementUI, {locale: 'en-us'}); // Use VCharts Vue.use(VCharts); +// Use Cookies +Vue.use(VueCookies); + // Init app new Vue({ render: (h) => h(App), From 446ed686bdbfa8e8accc470f1db07d1a29a7dd9f Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 10:05:53 -0400 Subject: [PATCH 07/45] [+] Create splash ascii art --- src/constants.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/constants.ts b/src/constants.ts index 3fcdd29..b21ec85 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -8,4 +8,8 @@ export default class Constants * TODO: Use https for actual usage */ public static API_URL: string = 'https://va.hydev.org/api'; + + public static SPLASH: string = '\\ / /\\ ._ _.| _ _ ._\n' + + ' \\/>< /--\\| |(_||\\//_(/_| \n' + + ' v0.1.1.0 / ' } From 9038a73678b0eaadf8c25c0ec27491e068256d4f Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 10:06:19 -0400 Subject: [PATCH 08/45] [+] Save cookies on login --- src/components/app/app.ts | 15 +++++++++++++-- src/components/app/app.vue | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/app/app.ts b/src/components/app/app.ts index ca45f70..ea1b630 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -55,13 +55,24 @@ export default class App extends Vue /** * This is called when the user logs in. * - * @param courses Courses Json + * @param token Authorization token */ - public onLogin(courses: Course[]) + public onLogin(token: string) { // Hide login bar this.showLogin = false; + // Save token to cookies + this.$cookies.set('va.token', token, '7d'); + } + + /** + * This is called when the user logs in. + * + * @param courses Courses Json + */ + public saveCourses(courses: Course[]) + { // Assign courses this.courses = courses; diff --git a/src/components/app/app.vue b/src/components/app/app.vue index baf4349..f04f91d 100644 --- a/src/components/app/app.vue +++ b/src/components/app/app.vue @@ -1,6 +1,6 @@