From 3575db818210f675d16ed33e59111098b1d7d45a Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:01:36 -0400 Subject: [PATCH 01/89] [+] Create css class for input error --- src/components/login/login.scss | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/login/login.scss b/src/components/login/login.scss index 45f0367..2b2b84f 100644 --- a/src/components/login/login.scss +++ b/src/components/login/login.scss @@ -72,3 +72,19 @@ width: 100%; } } + +// Error +.input-error +{ + .el-input__inner + { + color: #ff3a3a6b !important; + border-color: #ff3a3a6b !important; + background-color: #ffdddd3b !important; + } + + .el-input__inner:focus + { + background-color: white !important; + } +} From 0296b2151a75d3fa8d90f1fd2fe1cc94c71daf22 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:01:49 -0400 Subject: [PATCH 02/89] [+] Create error message field --- src/components/login/login.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index 91ca99b..095b540 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -13,6 +13,7 @@ export default class Login extends Vue public password: any = ''; public loading: boolean = false; + public error: String = 'asdf'; /** * On click, sends username and password to the server. From 8eb2080f14025c1ccdd3e3c271acfbac96a9193a Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:02:22 -0400 Subject: [PATCH 03/89] [+] Add error class on error --- src/components/login/login.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/login/login.vue b/src/components/login/login.vue index 31d14aa..979d0fe 100644 --- a/src/components/login/login.vue +++ b/src/components/login/login.vue @@ -3,9 +3,20 @@ From 5029555c21fbc160268c8cab3390484492dacde6 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:02:50 -0400 Subject: [PATCH 04/89] [U] Update api url --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index a946210..3fcdd29 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -7,5 +7,5 @@ export default class Constants * Base url for api access * TODO: Use https for actual usage */ - public static API_URL: string = 'http://cn2.hydev.org:24021/api'; + public static API_URL: string = 'https://va.hydev.org/api'; } From 9a752305e31553a6cc678ed096d4281c7fb64edf Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:23:34 -0400 Subject: [PATCH 05/89] [O] Fix error message styling --- src/components/login/login.scss | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/login/login.scss b/src/components/login/login.scss index 2b2b84f..691774a 100644 --- a/src/components/login/login.scss +++ b/src/components/login/login.scss @@ -88,3 +88,12 @@ background-color: white !important; } } + +// Fix error message +.el-form-item__error.custom +{ + padding-top: 0; + position: relative; + top: auto; + float: left; +} From 67ec2b85b2e4693ec724bb0a009533e4cbc24f6d Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:24:16 -0400 Subject: [PATCH 06/89] [+] Create error message div --- src/components/login/login.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/login/login.vue b/src/components/login/login.vue index 979d0fe..bd52eae 100644 --- a/src/components/login/login.vue +++ b/src/components/login/login.vue @@ -17,6 +17,8 @@ :class="{'input-error': error !== ''}"> +
{{error}}
+ Login From c7d16a00e6a262c90c552a67e3919cfe44bcaf49 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:28:24 -0400 Subject: [PATCH 07/89] [+] Send username and password to api in body --- src/components/login/login.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index 095b540..da99423 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -24,7 +24,9 @@ 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}/veracross/courses`).then(res => + fetch(`${Constants.API_URL}/api/login`, + {body: JSON.stringify({username: this.username, password: this.password})}) + .then(res => { // Get response body text res.text().then(text => From 805ffaa50e4d945ba69d22bb336b47b5a75a0593 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:28:54 -0400 Subject: [PATCH 08/89] [+] Check the success flag in response --- src/components/login/login.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index da99423..12a244f 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -31,8 +31,20 @@ export default class Login extends Vue // Get response body text res.text().then(text => { - // Call custom event with courses info - this.$emit('login:courses', JSON.parse(text)); + // Parse response + let response = JSON.parse(text); + + // Check success + if (response.success) + { + // Call custom event with courses info + this.$emit('login:token', response.token); + } + else + { + // Allow the user to retry + this.loading = false; + } }) }) .catch(err => From 75f9dc98499adfc399069bcec39108ec3ecb1ce4 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:31:32 -0400 Subject: [PATCH 09/89] [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 10/89] [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 11/89] [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 12/89] [+] 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 13/89] [+] 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 14/89] [+] 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 15/89] [+] 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 16/89] [+] 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 @@