From: Adam Dullage Date: Thu, 4 Aug 2022 11:51:16 +0000 (+0100) Subject: Re-design login view and implement login component. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=f8ba50c017c7db620cec7aca444e17764733c51c;p=flatnotes.git Re-design login view and implement login component. --- diff --git a/flatnotes/src/components/App.js b/flatnotes/src/components/App.js index 4a0b674..81549cc 100644 --- a/flatnotes/src/components/App.js +++ b/flatnotes/src/components/App.js @@ -3,6 +3,7 @@ import { Viewer } from "@toast-ui/vue-editor"; import RecentlyModified from "./RecentlyModified"; import LoadingIndicator from "./LoadingIndicator"; +import Login from "./Login"; import api from "../api"; import * as constants from "../constants"; @@ -16,6 +17,7 @@ export default { Editor, RecentlyModified, LoadingIndicator, + Login, }, data: function() { @@ -84,43 +86,6 @@ export default { (pageTitleSuffix ? `${pageTitleSuffix} - ` : "") + "flatnotes"; }, - login: function() { - let parent = this; - api - .post("/api/token", { - username: this.usernameInput, - password: this.passwordInput, - }) - .then(function(response) { - sessionStorage.setItem("token", response.data.access_token); - if (parent.rememberMeInput == true) { - localStorage.setItem("token", response.data.access_token); - } - let redirectPath = helpers.getSearchParam(constants.params.redirect); - parent.navigate(redirectPath || "/"); - }) - .catch(function(error) { - if (error.handled) { - return; - } else if ( - typeof error.response !== "undefined" && - [400, 422].includes(error.response.status) - ) { - parent.$bvToast.toast("Incorrect Username or Password ✘", { - variant: "danger", - noCloseButton: true, - }); - } else { - parent.unhandledServerErrorToast(); - } - }) - .finally(function() { - parent.usernameInput = null; - parent.passwordInput = null; - parent.rememberMeInput = false; - }); - }, - logout: function() { sessionStorage.removeItem("token"); localStorage.removeItem("token"); diff --git a/flatnotes/src/components/App.vue b/flatnotes/src/components/App.vue index 60bf9dc..23e8e62 100644 --- a/flatnotes/src/components/App.vue +++ b/flatnotes/src/components/App.vue @@ -1,238 +1,189 @@ diff --git a/flatnotes/src/components/Login.vue b/flatnotes/src/components/Login.vue new file mode 100644 index 0000000..0f9ee7b --- /dev/null +++ b/flatnotes/src/components/Login.vue @@ -0,0 +1,112 @@ + + + diff --git a/flatnotes/src/constants.js b/flatnotes/src/constants.js index 8f75422..ffea299 100644 --- a/flatnotes/src/constants.js +++ b/flatnotes/src/constants.js @@ -22,11 +22,6 @@ export const dataDefaults = function() { editMode: false, draftSaveTimeout: null, - // Login Data - usernameInput: null, - passwordInput: null, - rememberMeInput: false, - // Search Data searchFailed: false, diff --git a/flatnotes/src/index.html b/flatnotes/src/index.html index a205981..bb33b64 100644 --- a/flatnotes/src/index.html +++ b/flatnotes/src/index.html @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@ - +