From 815e71b943bb62f9858c4123fdc66ded5cfe0194 Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Wed, 28 Apr 2021 12:13:43 +0200 Subject: [PATCH 01/12] Ajout d'un LoginService pour s'authentifier --- ui2/public/favicon.ico | Bin 4286 -> 0 bytes ui2/public/index.html | 5 +- ui2/src/assets/img/logo.png | Bin 6849 -> 0 bytes ui2/src/components/login/Signin.vue | 17 +++-- ui2/src/config.js | 6 ++ ui2/src/locales/fr.json | 2 +- ui2/src/main.js | 9 ++- ui2/src/services/Fetcher.js | 96 ++++++++++++++++++++++++++++ ui2/src/services/LoginService.js | 16 +++++ ui2/src/views/LoginView.vue | 1 - 10 files changed, 139 insertions(+), 13 deletions(-) delete mode 100644 ui2/public/favicon.ico delete mode 100644 ui2/src/assets/img/logo.png create mode 100644 ui2/src/config.js create mode 100644 ui2/src/services/Fetcher.js create mode 100644 ui2/src/services/LoginService.js diff --git a/ui2/public/favicon.ico b/ui2/public/favicon.ico deleted file mode 100644 index df36fcfb72584e00488330b560ebcf34a41c64c2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kev<ISBgE$F{SFy+(=9Z)f)De0Se}ZDZW}Z3B zElCeVrw;K0Fdl_Cg=gZOFXXc3pL)Q05CAuT+XucQ<8g~3dteP~|7s7c6QYP;fy;mF zMN;>tV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?<QnEgvj4i?s}Yk=qA2z`-^*<eK3c)MS4JOdbsTQEOa0) z0NWqlna2rzs>5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7<X*Er!BfRbvU93$DH%#v6dRt^6HBxz1xBNHx=$&_Gv<&J}Ljk zJN<Fzx(`Oe@KgQ0F$<14=XV#WK`o#6Ku>z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{T<?%b6i9IjI)Ls)S{-*mq<@~R{?$}ZKjf;^k75i_}(2MXt}^SEBVg7AI@28 zo_uPg2V)_e-`2Ois=PYoe%9u*n9({PFR)OnHJPi{dNx>Kx<YG`4QQ>D#iCLfl2<BD h7L=-;Q>vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S diff --git a/ui2/public/index.html b/ui2/public/index.html index 56165dac2..82a14a087 100644 --- a/ui2/public/index.html +++ b/ui2/public/index.html @@ -4,12 +4,11 @@ <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> - <link rel="icon" href="<%= BASE_URL %>favicon.ico"> - <title>ORE</title> + <title>si-ore</title> </head> <body> <noscript> - <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> + <strong>We're sorry but si-ore doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> </noscript> <div id="app"></div> <!-- built files will be auto injected --> diff --git a/ui2/src/assets/img/logo.png b/ui2/src/assets/img/logo.png deleted file mode 100644 index f3d2503fc2a44b5053b0837ebea6e87a2d339a43..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6849 zcmaKRcUV(fvo}bjDT-7nLI_nlK}sT_69H+`qzVWDA|yaU?}j417wLi^B1KB1SLsC& zL0ag7$U(XW5YR7p&Ux?s<Na=)C)s<=p5LrlQ`Vj}i8j!?Lr2R_OGZXUr=_WGNV*Q3 zf2k=+zm;ZH`J@Y*r-qrQk(;BZj~xa<rsClC5CPOe**PH$5q1uK9)k!4GBOHYq_LT& znXV4h-VG&gcg`d3i*hHS$;cFxeBJHrT@aqYhX^Mm8V1^F=>P$d4lvMt8C^+TcQu4F zQqv!UF!I+kw)c0jhd6+g6oCr9P?7)?!qX1ui*iL{p}sKCAGuJ{{W)0z1pLF|=>h}& zt(2Lr0Z`2ig8<5i%Zk}cO5Fm=LByqGWaS`oqChZdEFmc`0hSb#gg|Aap^{+WKOYcj zHjINK)KDG%&s?Mt4CL(T=?;~U@bU2x_mLKN!#GJuK_CzbNw5SMEJorG!}_5;?R>@1 zSl)jns3WlU7^J%=(hUtfmuUCU&C3%8B5C^f5>W2Cy8jW3#{Od{lF1}|?c61##3dzA zsPlFG;l_FzBK}8>|H_Ru_H#!_7$UH4UKo3lKOA}g1(R&|e@}GINYVzX?q=_WLZCgh z)L|eJMce`D0EIwgRaNETDsr+?vQknSGAi=7H00r`QnI%oQnFxm`G2umXso9l+8*&Q z7WqF|$p49js$mdzo^BXpH#gURy=UO;=IMrYc5?@+sR4y_?d*~0^YP7d+y0{}0)zBM zIKVM(DBvICK#~7N0a+PY6)7;u=dutmNqK3AlsrUU9U`d;msiucB_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bR~l(0uY?O{OEVlaxa5@e%T&xju=o1`=OD#qc16 zSvyH*my(dcp6~VqR;o(#@m44Lug@~_qw+HA=mS#Z^<V!az}@c{ARa+_X}NO~a$=9p za)_Ly?(LOnFWV{rQbS?1K7hP~fC?!$z}<pP%6*k1O(nj^MX2}V?0EMJUI;+4&As(@ zxYB>4reBy8iV?H~I;{LQWk3aKK8$bLRyt$g?-<xQqj`npk`D=fcL`B%EgjfC99(LE z!z(C4-ap+uQYSIckaE<2uA^ag^t_eaYn_Jfq@U?vzOdv%t*)||aVad7PZ((`gpV!x rZ$0M!)qwuD?ff?h#CY04MnNVFTnmG)-+p%fr;?V2o_dw4E$;sThR3J6 diff --git a/ui2/src/components/login/Signin.vue b/ui2/src/components/login/Signin.vue index dbf6ee69c..789095823 100644 --- a/ui2/src/components/login/Signin.vue +++ b/ui2/src/components/login/Signin.vue @@ -5,12 +5,11 @@ rules="required|email" name="email" v-slot="{ errors, valid }" - v-id="email" + vid="email" > <b-field class="input-field" :type="{ - 'is-normal': disabled, 'is-danger': errors && errors.length > 0, 'is-success': valid, }" @@ -40,7 +39,6 @@ <b-field class="input-field" :type="{ - 'is-normal': disabled, 'is-danger': errors && errors.length > 0, 'is-success': valid, }" @@ -64,10 +62,14 @@ </section> <div class="buttons"> - <b-button type="is-primary" @click="handleSubmit(submit)"> + <b-button + type="is-primary" + @click="handleSubmit(submit)" + icon-right="plus" + > {{ $t("login.signin") }} </b-button> - <router-link :to="{ path: '/forgot-password/' + email }"> + <router-link :to="{ path: '/' }"> {{ $t("login.pwd-forgotten") }} </router-link> </div> @@ -77,16 +79,19 @@ <script> import { Component, Vue } from "vue-property-decorator"; import { ValidationObserver, ValidationProvider } from "vee-validate"; +import { LoginService } from "@/services/LoginService"; @Component({ components: { ValidationObserver, ValidationProvider }, }) export default class SignIn extends Vue { + loginService = LoginService.INSTANCE; + email = ""; password = ""; submit() { - console.log(this.email, this.password); + this.loginService.signIn(this.email, this.password); } } </script> diff --git a/ui2/src/config.js b/ui2/src/config.js new file mode 100644 index 000000000..d4b22d17a --- /dev/null +++ b/ui2/src/config.js @@ -0,0 +1,6 @@ +export default { + BASE: "http://localhost:8081/api/v1/", + API_URL: "http://localhost:8081/api/v1/", + WS_URL: "wss://localhost:8081/api/V1/", + SWAGGER: "http://localhost:8081/swagger-ui.html", +}; diff --git a/ui2/src/locales/fr.json b/ui2/src/locales/fr.json index 79900fecc..3eb9c100b 100644 --- a/ui2/src/locales/fr.json +++ b/ui2/src/locales/fr.json @@ -1,6 +1,6 @@ { "titles": { - "login-page": "Bienvenue sur ORE" + "login-page": "Bienvenue sur SI-ORE" }, "login": { "signin": "Se connecter", diff --git a/ui2/src/main.js b/ui2/src/main.js index 2476b2995..31eb8a635 100644 --- a/ui2/src/main.js +++ b/ui2/src/main.js @@ -4,9 +4,14 @@ import router from "./router"; import Buefy from "buefy"; import { library } from "@fortawesome/fontawesome-svg-core"; -import { faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons"; +import { + faExclamationCircle, + faEye, + faEyeSlash, + faPlus, +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; -library.add(faEye, faEyeSlash); +library.add(faEye, faEyeSlash, faPlus, faExclamationCircle); Vue.component("vue-fontawesome", FontAwesomeIcon); import "@/style/global.scss"; diff --git a/ui2/src/services/Fetcher.js b/ui2/src/services/Fetcher.js new file mode 100644 index 000000000..a1251c152 --- /dev/null +++ b/ui2/src/services/Fetcher.js @@ -0,0 +1,96 @@ +import { EventEmitter } from "events"; +import config from "@/config"; + +export class Fetcher extends EventEmitter { + async post(url, data) { + const formData = this.convertToFormData(data); + + const response = await fetch(`${config.API_URL}${url}`, { + method: "POST", + mode: "cors", + credentials: "include", + body: formData, + }); + + return this._handleResponse(response); + } + + async put(url, data) { + const formData = this.convertToFormData(data); + const response = await fetch(`${config.API_URL}${url}`, { + method: "PUT", + mode: "cors", + credentials: "include", + body: formData, + }); + + return this._handleResponse(response); + } + + async get(url, params = {}) { + const path = new URL(url, config.API_URL); + + Object.entries(params).forEach(([name, value]) => { + if (Array.isArray(value)) { + value.forEach((v) => { + path.searchParams.append(name, v); + }); + } else { + path.searchParams.append(name, value); + } + }); + + const response = await fetch(path, { + method: "GET", + mode: "cors", + credentials: "include", + }); + + return this._handleResponse(response); + } + + async delete(url, data) { + const formData = this.convertToFormData(data); + const response = await fetch(`${config.API_URL}${url}`, { + method: "DELETE", + mode: "cors", + credentials: "include", + body: formData, + }); + + if (response.ok) { + return Promise.resolve(); + } + + return Promise.reject({ status: response.status }); + } + + async _handleResponse(response) { + let result = ""; + try { + if (response.status !== 204) { + result = await response.json(); + } + } catch (e) { + console.error(e); + } + + if (response.ok) { + return Promise.resolve(result); + } + + return Promise.reject({ status: response.status }); + } + + convertToFormData(body) { + let formData = new FormData(); + if (body) { + for (const [key, value] of Object.entries(body)) { + console.log(`${key}: ${value}`); + formData.append(key.toString(), value.toString()); + console.log("FOR", formData); + } + } + return formData; + } +} diff --git a/ui2/src/services/LoginService.js b/ui2/src/services/LoginService.js new file mode 100644 index 000000000..01396f09b --- /dev/null +++ b/ui2/src/services/LoginService.js @@ -0,0 +1,16 @@ +import { Fetcher } from "@/services/Fetcher.js"; + +export class LoginService extends Fetcher { + static INSTANCE = new LoginService(); + + constructor() { + super(); + } + + async signIn(email, pwd) { + return this.post("login", { + login: email, + password: pwd, + }); + } +} diff --git a/ui2/src/views/LoginView.vue b/ui2/src/views/LoginView.vue index 01260d52a..f32b17bee 100644 --- a/ui2/src/views/LoginView.vue +++ b/ui2/src/views/LoginView.vue @@ -6,7 +6,6 @@ <b-tab-item :label="$t('login.signin')"> <SignIn /> </b-tab-item> - <b-tab-item :label="$t('login.signup')">À venir</b-tab-item> </b-tabs> </div> </PageView> -- GitLab From 7ab32607e2b8bbce936d151826762ba4ff46ea44 Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Wed, 28 Apr 2021 12:20:58 +0200 Subject: [PATCH 02/12] Remplace l'email par un login --- ui2/src/components/login/Signin.vue | 20 ++++++++------------ ui2/src/locales/fr.json | 4 ++-- ui2/src/services/LoginService.js | 4 ++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/ui2/src/components/login/Signin.vue b/ui2/src/components/login/Signin.vue index 789095823..d05f0c827 100644 --- a/ui2/src/components/login/Signin.vue +++ b/ui2/src/components/login/Signin.vue @@ -2,10 +2,10 @@ <ValidationObserver ref="observer" v-slot="{ handleSubmit }"> <section> <ValidationProvider - rules="required|email" - name="email" + rules="required" + name="login" v-slot="{ errors, valid }" - vid="email" + vid="login" > <b-field class="input-field" @@ -16,23 +16,19 @@ :message="errors[0]" > <template slot="label"> - {{ $t("login.email") }} + {{ $t("login.login") }} <span class="mandatory"> {{ $t("validation.obligatoire") }} </span> </template> - <b-input - type="email" - v-model="email" - :placeholder="$t('login.email-placeholder')" - > + <b-input v-model="login" :placeholder="$t('login.login-placeholder')"> </b-input> </b-field> </ValidationProvider> <ValidationProvider rules="required" - name="email" + name="password" v-slot="{ errors, valid }" vid="password" > @@ -87,11 +83,11 @@ import { LoginService } from "@/services/LoginService"; export default class SignIn extends Vue { loginService = LoginService.INSTANCE; - email = ""; + login = ""; password = ""; submit() { - this.loginService.signIn(this.email, this.password); + this.loginService.signIn(this.login, this.password); } } </script> diff --git a/ui2/src/locales/fr.json b/ui2/src/locales/fr.json index 3eb9c100b..8bd935ab0 100644 --- a/ui2/src/locales/fr.json +++ b/ui2/src/locales/fr.json @@ -5,8 +5,8 @@ "login": { "signin": "Se connecter", "signup": "Créer un compte", - "email": "Email", - "email-placeholder": "Entrer l'adresse mail", + "login": "Login", + "login-placeholder": "Entrer le login", "pwd": "Mot de passe", "pwd-placeholder": "Entrer le mot de passe", "pwd-forgotten": "Mot de passe oublié ?" diff --git a/ui2/src/services/LoginService.js b/ui2/src/services/LoginService.js index 01396f09b..594aed2a7 100644 --- a/ui2/src/services/LoginService.js +++ b/ui2/src/services/LoginService.js @@ -7,9 +7,9 @@ export class LoginService extends Fetcher { super(); } - async signIn(email, pwd) { + async signIn(login, pwd) { return this.post("login", { - login: email, + login: login, password: pwd, }); } -- GitLab From 90e5b1f40a01e632422e16ad037194810765580e Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Wed, 28 Apr 2021 16:40:19 +0200 Subject: [PATCH 03/12] =?UTF-8?q?Service=20d'alert=20ajout=C3=A9=20pour=20?= =?UTF-8?q?l'affichage=20d'erreurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui2/src/components/login/Signin.vue | 17 +- ui2/src/locales/fr.json | 5 + ui2/src/main.js | 3 +- ui2/src/services/AlertService.js | 42 ++++ ui2/src/services/Fetcher.js | 16 +- ui2/src/utils/BuefyUtils.js | 5 + ui2/src/utils/HttpUtils.js | 378 ++++++++++++++++++++++++++++ 7 files changed, 448 insertions(+), 18 deletions(-) create mode 100644 ui2/src/services/AlertService.js create mode 100644 ui2/src/utils/BuefyUtils.js create mode 100644 ui2/src/utils/HttpUtils.js diff --git a/ui2/src/components/login/Signin.vue b/ui2/src/components/login/Signin.vue index d05f0c827..9afed9a4d 100644 --- a/ui2/src/components/login/Signin.vue +++ b/ui2/src/components/login/Signin.vue @@ -60,7 +60,7 @@ <div class="buttons"> <b-button type="is-primary" - @click="handleSubmit(submit)" + @click="handleSubmit(signIn)" icon-right="plus" > {{ $t("login.signin") }} @@ -76,18 +76,29 @@ import { Component, Vue } from "vue-property-decorator"; import { ValidationObserver, ValidationProvider } from "vee-validate"; import { LoginService } from "@/services/LoginService"; +import { AlertService } from "@/services/AlertService"; +import { HttpStatusCodes } from "@/utils/HttpUtils"; @Component({ components: { ValidationObserver, ValidationProvider }, }) export default class SignIn extends Vue { loginService = LoginService.INSTANCE; + alertService = AlertService.INSTANCE; login = ""; password = ""; - submit() { - this.loginService.signIn(this.login, this.password); + async signIn() { + try { + await this.loginService.signIn(this.login, this.password); + } catch (error) { + let message = this.$t("alert.server-error"); + if (error.status === HttpStatusCodes.FORBIDDEN) { + message = this.$t("alert.user-uknown"); + } + this.alertService.toastError(message, error); + } } } </script> diff --git a/ui2/src/locales/fr.json b/ui2/src/locales/fr.json index 8bd935ab0..591bb7c42 100644 --- a/ui2/src/locales/fr.json +++ b/ui2/src/locales/fr.json @@ -16,5 +16,10 @@ "facultatif": "Facultatif", "invalid-required": "Merci de remplir le champ", "invalid-email": "Merci de renseigner un email valide" + }, + "alert": { + "cancel": "Annuler", + "server-error": "Une erreur serveur est survenue", + "user-uknown": "Identifiants inconnus" } } diff --git a/ui2/src/main.js b/ui2/src/main.js index 31eb8a635..da2712537 100644 --- a/ui2/src/main.js +++ b/ui2/src/main.js @@ -5,13 +5,14 @@ import router from "./router"; import Buefy from "buefy"; import { library } from "@fortawesome/fontawesome-svg-core"; import { + faCheck, faExclamationCircle, faEye, faEyeSlash, faPlus, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; -library.add(faEye, faEyeSlash, faPlus, faExclamationCircle); +library.add(faEye, faEyeSlash, faPlus, faExclamationCircle, faCheck); Vue.component("vue-fontawesome", FontAwesomeIcon); import "@/style/global.scss"; diff --git a/ui2/src/services/AlertService.js b/ui2/src/services/AlertService.js new file mode 100644 index 000000000..1dd5c289d --- /dev/null +++ b/ui2/src/services/AlertService.js @@ -0,0 +1,42 @@ +import { BuefyTypes } from "@/utils/BuefyUtils"; +import { ToastProgrammatic } from "buefy"; + +const TOAST_INFO_DURATION = 3000; +const TOAST_ERROR_DURATION = 8000; +const TOAST_POSITION = "is-top"; + +/** + * Un service pour gérer les différents messages d'alerte et popup d'info s'affichant sur l'application + */ +export class AlertService { + static INSTANCE = new AlertService(); + + toastSuccess(message) { + ToastProgrammatic.open({ + message: message, + type: BuefyTypes.SUCCESS, + duration: TOAST_INFO_DURATION, + position: TOAST_POSITION, + }); + } + + toastWarn(message, error) { + console.warn("[WARNING] " + message, error); + ToastProgrammatic.open({ + message: message, + type: BuefyTypes.WARNING, + duration: TOAST_ERROR_DURATION, + position: TOAST_POSITION, + }); + } + + toastError(message, error) { + console.error("[ERROR] " + message, error); + ToastProgrammatic.open({ + message: message, + type: BuefyTypes.DANGER, + duration: TOAST_ERROR_DURATION, + position: TOAST_POSITION, + }); + } +} diff --git a/ui2/src/services/Fetcher.js b/ui2/src/services/Fetcher.js index a1251c152..2a47f2e96 100644 --- a/ui2/src/services/Fetcher.js +++ b/ui2/src/services/Fetcher.js @@ -1,7 +1,6 @@ -import { EventEmitter } from "events"; import config from "@/config"; -export class Fetcher extends EventEmitter { +export class Fetcher { async post(url, data) { const formData = this.convertToFormData(data); @@ -66,17 +65,8 @@ export class Fetcher extends EventEmitter { } async _handleResponse(response) { - let result = ""; - try { - if (response.status !== 204) { - result = await response.json(); - } - } catch (e) { - console.error(e); - } - if (response.ok) { - return Promise.resolve(result); + return Promise.resolve(); } return Promise.reject({ status: response.status }); @@ -86,9 +76,7 @@ export class Fetcher extends EventEmitter { let formData = new FormData(); if (body) { for (const [key, value] of Object.entries(body)) { - console.log(`${key}: ${value}`); formData.append(key.toString(), value.toString()); - console.log("FOR", formData); } } return formData; diff --git a/ui2/src/utils/BuefyUtils.js b/ui2/src/utils/BuefyUtils.js new file mode 100644 index 000000000..a93395fc0 --- /dev/null +++ b/ui2/src/utils/BuefyUtils.js @@ -0,0 +1,5 @@ +export const BuefyTypes = { + SUCCESS: "is-success", + WARNING: "is-warning", + DANGER: "is-danger", +}; diff --git a/ui2/src/utils/HttpUtils.js b/ui2/src/utils/HttpUtils.js new file mode 100644 index 000000000..e953459f6 --- /dev/null +++ b/ui2/src/utils/HttpUtils.js @@ -0,0 +1,378 @@ +/** + * Hypertext Transfer Protocol (HTTP) response status codes. + * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes} + */ +export const HttpStatusCodes = { + /** + * The server has received the request headers and the client should proceed to send the request body + * (in the case of a request for which a body needs to be sent; for example, a POST request). + * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient. + * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request + * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued. + */ + CONTINUE: 100, + + /** + * The requester has asked the server to switch protocols and the server has agreed to do so. + */ + SWITCHING_PROTOCOLS: 101, + + /** + * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request. + * This code indicates that the server has received and is processing the request, but no response is available yet. + * This prevents the client from timing out and assuming the request was lost. + */ + PROCESSING: 102, + + /** + * Standard response for successful HTTP requests. + * The actual response will depend on the request method used. + * In a GET request, the response will contain an entity corresponding to the requested resource. + * In a POST request, the response will contain an entity describing or containing the result of the action. + */ + OK: 200, + + /** + * The request has been fulfilled, resulting in the creation of a new resource. + */ + CREATED: 201, + + /** + * The request has been accepted for processing, but the processing has not been completed. + * The request might or might not be eventually acted upon, and may be disallowed when processing occurs. + */ + ACCEPTED: 202, + + /** + * SINCE HTTP/1.1 + * The server is a transforming proxy that received a 200 OK from its origin, + * but is returning a modified version of the origin's response. + */ + NON_AUTHORITATIVE_INFORMATION: 203, + + /** + * The server successfully processed the request and is not returning any content. + */ + NO_CONTENT: 204, + + /** + * The server successfully processed the request, but is not returning any content. + * Unlike a 204 response, this response requires that the requester reset the document view. + */ + RESET_CONTENT: 205, + + /** + * The server is delivering only part of the resource (byte serving) due to a range header sent by the client. + * The range header is used by HTTP clients to enable resuming of interrupted downloads, + * or split a download into multiple simultaneous streams. + */ + PARTIAL_CONTENT: 206, + + /** + * The message body that follows is an XML message and can contain a number of separate response codes, + * depending on how many sub-requests were made. + */ + MULTI_STATUS: 207, + + /** + * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response, + * and are not being included again. + */ + ALREADY_REPORTED: 208, + + /** + * The server has fulfilled a request for the resource, + * and the response is a representation of the result of one or more instance-manipulations applied to the current instance. + */ + IM_USED: 226, + + /** + * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation). + * For example, this code could be used to present multiple video format options, + * to list files with different filename extensions, or to suggest word-sense disambiguation. + */ + MULTIPLE_CHOICES: 300, + + /** + * This and all future requests should be directed to the given URI. + */ + MOVED_PERMANENTLY: 301, + + /** + * This is an example of industry practice contradicting the standard. + * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect + * (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302 + * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307 + * to distinguish between the two behaviours. However, some Web applications and frameworks + * use the 302 status code as if it were the 303. + */ + FOUND: 302, + + /** + * SINCE HTTP/1.1 + * The response to the request can be found under another URI using a GET method. + * When received in response to a POST (or PUT/DELETE), the client should presume that + * the server has received the data and should issue a redirect with a separate GET message. + */ + SEE_OTHER: 303, + + /** + * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match. + * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy. + */ + NOT_MODIFIED: 304, + + /** + * SINCE HTTP/1.1 + * The requested resource is available only through a proxy, the address for which is provided in the response. + * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons. + */ + USE_PROXY: 305, + + /** + * No longer used. Originally meant "Subsequent requests should use the specified proxy." + */ + SWITCH_PROXY: 306, + + /** + * SINCE HTTP/1.1 + * In this case, the request should be repeated with another URI; however, future requests should still use the original URI. + * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request. + * For example, a POST request should be repeated using another POST request. + */ + TEMPORARY_REDIRECT: 307, + + /** + * The request and all future requests should be repeated using another URI. + * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change. + * So, for example, submitting a form to a permanently redirected resource may continue smoothly. + */ + PERMANENT_REDIRECT: 308, + + /** + * The server cannot or will not process the request due to an apparent client error + * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing). + */ + BAD_REQUEST: 400, + + /** + * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet + * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the + * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means + * "unauthenticated",i.e. the user does not have the necessary credentials. + */ + UNAUTHORIZED: 401, + + /** + * Reserved for future use. The original intention was that this code might be used as part of some form of digital + * cash or micro payment scheme, but that has not happened, and this code is not usually used. + * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests. + */ + PAYMENT_REQUIRED: 402, + + /** + * The request was valid, but the server is refusing action. + * The user might not have the necessary permissions for a resource. + */ + FORBIDDEN: 403, + + /** + * The requested resource could not be found but may be available in the future. + * Subsequent requests by the client are permissible. + */ + NOT_FOUND: 404, + + /** + * A request method is not supported for the requested resource; + * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource. + */ + METHOD_NOT_ALLOWED: 405, + + /** + * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request. + */ + NOT_ACCEPTABLE: 406, + + /** + * The client must first authenticate itself with the proxy. + */ + PROXY_AUTHENTICATION_REQUIRED: 407, + + /** + * The server timed out waiting for the request. + * According to HTTP specifications: + * "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time." + */ + REQUEST_TIMEOUT: 408, + + /** + * Indicates that the request could not be processed because of conflict in the request, + * such as an edit conflict between multiple simultaneous updates. + */ + CONFLICT: 409, + + /** + * Indicates that the resource requested is no longer available and will not be available again. + * This should be used when a resource has been intentionally removed and the resource should be purged. + * Upon receiving a 410 status code, the client should not request the resource in the future. + * Clients such as search engines should remove the resource from their indices. + * Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead. + */ + GONE: 410, + + /** + * The request did not specify the length of its content, which is required by the requested resource. + */ + LENGTH_REQUIRED: 411, + + /** + * The server does not meet one of the preconditions that the requester put on the request. + */ + PRECONDITION_FAILED: 412, + + /** + * The request is larger than the server is willing or able to process. Previously called "Request Entity Too Large". + */ + PAYLOAD_TOO_LARGE: 413, + + /** + * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request, + * in which case it should be converted to a POST request. + * Called "Request-URI Too Long" previously. + */ + URI_TOO_LONG: 414, + + /** + * The request entity has a media type which the server or resource does not support. + * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format. + */ + UNSUPPORTED_MEDIA_TYPE: 415, + + /** + * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion. + * For example, if the client asked for a part of the file that lies beyond the end of the file. + * Called "Requested Range Not Satisfiable" previously. + */ + RANGE_NOT_SATISFIABLE: 416, + + /** + * The server cannot meet the requirements of the Expect request-header field. + */ + EXPECTATION_FAILED: 417, + + /** + * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, + * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by + * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com. + */ + I_AM_A_TEAPOT: 418, + + /** + * The request was directed at a server that is not able to produce a response (for example because a connection reuse). + */ + MISDIRECTED_REQUEST: 421, + + /** + * The request was well-formed but was unable to be followed due to semantic errors. + */ + UNPROCESSABLE_ENTITY: 422, + + /** + * The resource that is being accessed is locked. + */ + LOCKED: 423, + + /** + * The request failed due to failure of a previous request (e.g., a PROPPATCH). + */ + FAILED_DEPENDENCY: 424, + + /** + * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field. + */ + UPGRADE_REQUIRED: 426, + + /** + * The origin server requires the request to be conditional. + * Intended to prevent "the 'lost update' problem, where a client + * GETs a resource's state, modifies it, and PUTs it back to the server, + * when meanwhile a third party has modified the state on the server, leading to a conflict." + */ + PRECONDITION_REQUIRED: 428, + + /** + * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes. + */ + TOO_MANY_REQUESTS: 429, + + /** + * The server is unwilling to process the request because either an individual header field, + * or all the header fields collectively, are too large. + */ + REQUEST_HEADER_FIELDS_TOO_LARGE: 431, + + /** + * A server operator has received a legal demand to deny access to a resource or to a set of resources + * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451. + */ + UNAVAILABLE_FOR_LEGAL_REASONS: 451, + + /** + * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable. + */ + INTERNAL_SERVER_ERROR: 500, + + /** + * The server either does not recognize the request method, or it lacks the ability to fulfill the request. + * Usually this implies future availability (e.g., a new feature of a web-service API). + */ + NOT_IMPLEMENTED: 501, + + /** + * The server was acting as a gateway or proxy and received an invalid response from the upstream server. + */ + BAD_GATEWAY: 502, + + /** + * The server is currently unavailable (because it is overloaded or down for maintenance). + * Generally, this is a temporary state. + */ + SERVICE_UNAVAILABLE: 503, + + /** + * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server. + */ + GATEWAY_TIMEOUT: 504, + + /** + * The server does not support the HTTP protocol version used in the request + */ + HTTP_VERSION_NOT_SUPPORTED: 505, + + /** + * Transparent content negotiation for the request results in a circular reference. + */ + VARIANT_ALSO_NEGOTIATES: 506, + + /** + * The server is unable to store the representation needed to complete the request. + */ + INSUFFICIENT_STORAGE: 507, + + /** + * The server detected an infinite loop while processing the request. + */ + LOOP_DETECTED: 508, + + /** + * Further extensions to the request are required for the server to fulfill it. + */ + NOT_EXTENDED: 510, + + /** + * The client needs to authenticate to gain network access. + * Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used + * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot). + */ + NETWORK_AUTHENTICATION_REQUIRED: 511, +}; -- GitLab From 288e2ac1cfb47b59c80ad0f3f5763c4b2175c504 Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Wed, 28 Apr 2021 17:30:38 +0200 Subject: [PATCH 04/12] =?UTF-8?q?Sauve=20l'utilisateur=20connect=C3=A9=20d?= =?UTF-8?q?ans=20le=20local=20storage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui2/src/locales/fr.json | 3 ++- ui2/src/main.js | 4 +++- ui2/src/model/User.js | 15 +++++++++++++++ ui2/src/router/index.js | 6 ++++++ ui2/src/services/Fetcher.js | 5 +++-- ui2/src/services/LoginService.js | 20 +++++++++++++++++++- ui2/src/views/ApplicationsView.vue | 30 ++++++++++++++++++++++++++++++ 7 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 ui2/src/model/User.js create mode 100644 ui2/src/views/ApplicationsView.vue diff --git a/ui2/src/locales/fr.json b/ui2/src/locales/fr.json index 591bb7c42..ad4604a3b 100644 --- a/ui2/src/locales/fr.json +++ b/ui2/src/locales/fr.json @@ -1,6 +1,7 @@ { "titles": { - "login-page": "Bienvenue sur SI-ORE" + "login-page": "Bienvenue sur SI-ORE", + "applications-page": "Applications" }, "login": { "signin": "Se connecter", diff --git a/ui2/src/main.js b/ui2/src/main.js index da2712537..c86ae3192 100644 --- a/ui2/src/main.js +++ b/ui2/src/main.js @@ -31,8 +31,10 @@ Vue.use(Buefy, { Vue.config.productionTip = false; -new Vue({ +const app = new Vue({ router, i18n, render: (h) => h(App), }).$mount("#app"); + +export default app; diff --git a/ui2/src/model/User.js b/ui2/src/model/User.js new file mode 100644 index 000000000..2fe764076 --- /dev/null +++ b/ui2/src/model/User.js @@ -0,0 +1,15 @@ +export class User { + creationDate; + id; + login; + password; + updateDate; + + constructor() { + this.creationDate = new Date(); + this.id = ""; + this.login = ""; + this.password = ""; + this.updateDate = new Date(); + } +} diff --git a/ui2/src/router/index.js b/ui2/src/router/index.js index c5abb4c2d..7a2f5f33a 100644 --- a/ui2/src/router/index.js +++ b/ui2/src/router/index.js @@ -1,6 +1,7 @@ import Vue from "vue"; import VueRouter from "vue-router"; import LoginView from "@/views/LoginView.vue"; +import ApplicationsView from "@/views/ApplicationsView.vue"; Vue.use(VueRouter); @@ -14,6 +15,11 @@ const routes = [ name: "Login", component: LoginView, }, + { + path: "/applications", + name: "Applications", + component: ApplicationsView, + }, ]; const router = new VueRouter({ diff --git a/ui2/src/services/Fetcher.js b/ui2/src/services/Fetcher.js index 2a47f2e96..827c8fd03 100644 --- a/ui2/src/services/Fetcher.js +++ b/ui2/src/services/Fetcher.js @@ -58,7 +58,7 @@ export class Fetcher { }); if (response.ok) { - return Promise.resolve(); + return Promise.resolve(response); } return Promise.reject({ status: response.status }); @@ -66,7 +66,8 @@ export class Fetcher { async _handleResponse(response) { if (response.ok) { - return Promise.resolve(); + const text = await response.text(); + return Promise.resolve(JSON.parse(text)); } return Promise.reject({ status: response.status }); diff --git a/ui2/src/services/LoginService.js b/ui2/src/services/LoginService.js index 594aed2a7..eecc55cea 100644 --- a/ui2/src/services/LoginService.js +++ b/ui2/src/services/LoginService.js @@ -1,16 +1,34 @@ +import app from "@/main"; +import { User } from "@/model/User"; import { Fetcher } from "@/services/Fetcher.js"; +const LOCAL_STORAGE_LOGGUED_USER = "loggedUser"; + export class LoginService extends Fetcher { static INSTANCE = new LoginService(); + loggedUser = new User(); constructor() { super(); } + getLoggedUser() { + return this.loggedUser; + } + async signIn(login, pwd) { - return this.post("login", { + let response = await this.post("login", { login: login, password: pwd, }); + + this.loggedUser = response; + localStorage.setItem( + LOCAL_STORAGE_LOGGUED_USER, + JSON.stringify(this.loggedUser) + ); + + app.$router.push("/applications"); + return Promise.resolve(response); } } diff --git a/ui2/src/views/ApplicationsView.vue b/ui2/src/views/ApplicationsView.vue new file mode 100644 index 000000000..b6a50ee74 --- /dev/null +++ b/ui2/src/views/ApplicationsView.vue @@ -0,0 +1,30 @@ +<template> + <PageView class="LoginView"> + <h1 class="title main-title">{{ $t("titles.applications-page") }}</h1> + {{ loggedUser.login }} + </PageView> +</template> + +<script> +import { User } from "@/model/User"; +import { LoginService } from "@/services/LoginService"; +import { Component, Vue } from "vue-property-decorator"; +import PageView from "./common/PageView.vue"; + +@Component({ + components: { PageView }, +}) +export default class ApplicationsView extends Vue { + loginService = LoginService.INSTANCE; + + loggedUser = new User(); + + created() { + this.init(); + } + + async init() { + this.loggedUser = await this.loginService.getLoggedUser(); + } +} +</script> -- GitLab From 23587c833515a59a1c98e8bffe2f1c25d280f1ee Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Thu, 29 Apr 2021 13:07:17 +0200 Subject: [PATCH 05/12] Ajout d'un menu. --- ui2/src/locales/fr.json | 12 +++-- ui2/src/main.js | 10 +++- ui2/src/router/index.js | 6 +++ ui2/src/services/LoginService.js | 4 ++ ui2/src/style/_variables.scss | 5 +- ui2/src/views/ApplicationsView.vue | 14 +++-- ui2/src/views/ReferencesView.vue | 34 ++++++++++++ ui2/src/views/common/MenuView.vue | 86 ++++++++++++++++++++++++++++++ 8 files changed, 161 insertions(+), 10 deletions(-) create mode 100644 ui2/src/views/ReferencesView.vue create mode 100644 ui2/src/views/common/MenuView.vue diff --git a/ui2/src/locales/fr.json b/ui2/src/locales/fr.json index ad4604a3b..473d57694 100644 --- a/ui2/src/locales/fr.json +++ b/ui2/src/locales/fr.json @@ -1,13 +1,14 @@ { "titles": { "login-page": "Bienvenue sur SI-ORE", - "applications-page": "Applications" + "applications-page": "Mes applications", + "references-page": "Mes référentiels" }, "login": { "signin": "Se connecter", "signup": "Créer un compte", - "login": "Login", - "login-placeholder": "Entrer le login", + "login": "Identifiant", + "login-placeholder": "Entrer l'identifiant", "pwd": "Mot de passe", "pwd-placeholder": "Entrer le mot de passe", "pwd-forgotten": "Mot de passe oublié ?" @@ -22,5 +23,10 @@ "cancel": "Annuler", "server-error": "Une erreur serveur est survenue", "user-uknown": "Identifiants inconnus" + }, + "menu": { + "logout": "Se déconnecter", + "applications": "Applications", + "references": "Référentiels" } } diff --git a/ui2/src/main.js b/ui2/src/main.js index c86ae3192..a22b78599 100644 --- a/ui2/src/main.js +++ b/ui2/src/main.js @@ -10,9 +10,17 @@ import { faEye, faEyeSlash, faPlus, + faSignOutAlt, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; -library.add(faEye, faEyeSlash, faPlus, faExclamationCircle, faCheck); +library.add( + faEye, + faEyeSlash, + faPlus, + faExclamationCircle, + faCheck, + faSignOutAlt +); Vue.component("vue-fontawesome", FontAwesomeIcon); import "@/style/global.scss"; diff --git a/ui2/src/router/index.js b/ui2/src/router/index.js index 7a2f5f33a..2a8cacc64 100644 --- a/ui2/src/router/index.js +++ b/ui2/src/router/index.js @@ -2,6 +2,7 @@ import Vue from "vue"; import VueRouter from "vue-router"; import LoginView from "@/views/LoginView.vue"; import ApplicationsView from "@/views/ApplicationsView.vue"; +import ReferencesView from "@/views/ReferencesView.vue"; Vue.use(VueRouter); @@ -20,6 +21,11 @@ const routes = [ name: "Applications", component: ApplicationsView, }, + { + path: "/references", + name: "References", + component: ReferencesView, + }, ]; const router = new VueRouter({ diff --git a/ui2/src/services/LoginService.js b/ui2/src/services/LoginService.js index eecc55cea..18236662e 100644 --- a/ui2/src/services/LoginService.js +++ b/ui2/src/services/LoginService.js @@ -31,4 +31,8 @@ export class LoginService extends Fetcher { app.$router.push("/applications"); return Promise.resolve(response); } + + logout() { + return this.delete("logout"); + } } diff --git a/ui2/src/style/_variables.scss b/ui2/src/style/_variables.scss index e7d750bae..b1238867d 100644 --- a/ui2/src/style/_variables.scss +++ b/ui2/src/style/_variables.scss @@ -5,11 +5,14 @@ $font-family: "LiberationSans", Helvetica, Arial, sans-serif; $text-default-color: #2c3e50; - +$light-text: rgb(230, 230, 230); // InputWithValidation $input-field-margin-bot: 1rem; $input-help-margin-top: 0.25rem; +// MenuView +$menu-height: 80px; + /************************************************************************************************** * Buefy/Bulma customizations * * see all customizable variables here https://buefy.org/documentation/customization/ * diff --git a/ui2/src/views/ApplicationsView.vue b/ui2/src/views/ApplicationsView.vue index b6a50ee74..6d2f182a1 100644 --- a/ui2/src/views/ApplicationsView.vue +++ b/ui2/src/views/ApplicationsView.vue @@ -1,18 +1,22 @@ <template> - <PageView class="LoginView"> - <h1 class="title main-title">{{ $t("titles.applications-page") }}</h1> - {{ loggedUser.login }} - </PageView> + <div> + <MenuView /> + <PageView> + <h1 class="title main-title">{{ $t("titles.applications-page") }}</h1> + {{ loggedUser.login }} + </PageView> + </div> </template> <script> import { User } from "@/model/User"; import { LoginService } from "@/services/LoginService"; import { Component, Vue } from "vue-property-decorator"; +import MenuView from "./common/MenuView.vue"; import PageView from "./common/PageView.vue"; @Component({ - components: { PageView }, + components: { PageView, MenuView }, }) export default class ApplicationsView extends Vue { loginService = LoginService.INSTANCE; diff --git a/ui2/src/views/ReferencesView.vue b/ui2/src/views/ReferencesView.vue new file mode 100644 index 000000000..f7e249c3d --- /dev/null +++ b/ui2/src/views/ReferencesView.vue @@ -0,0 +1,34 @@ +<template> + <div> + <MenuView /> + <PageView class="LoginView"> + <h1 class="title main-title">{{ $t("titles.references-page") }}</h1> + {{ loggedUser.login }} + </PageView> + </div> +</template> + +<script> +import { User } from "@/model/User"; +import { LoginService } from "@/services/LoginService"; +import { Component, Vue } from "vue-property-decorator"; +import MenuView from "./common/MenuView.vue"; +import PageView from "./common/PageView.vue"; + +@Component({ + components: { PageView, MenuView }, +}) +export default class ReferencesView extends Vue { + loginService = LoginService.INSTANCE; + + loggedUser = new User(); + + created() { + this.init(); + } + + async init() { + this.loggedUser = await this.loginService.getLoggedUser(); + } +} +</script> diff --git a/ui2/src/views/common/MenuView.vue b/ui2/src/views/common/MenuView.vue new file mode 100644 index 000000000..99ed5c656 --- /dev/null +++ b/ui2/src/views/common/MenuView.vue @@ -0,0 +1,86 @@ +<template> + <b-navbar class="menu-view"> + <template #start> + <b-navbar-item tag="router-link" :to="{ path: '/applications' }"> + {{ $t("menu.applications") }} + </b-navbar-item> + <b-navbar-item tag="router-link" :to="{ path: '/references' }"> + {{ $t("menu.references") }} + </b-navbar-item> + </template> + + <template #end> + <b-navbar-item tag="div"> + <div class="buttons"> + <b-button type="is-info" @click="logout" icon-right="sign-out-alt">{{ + $t("menu.logout") + }}</b-button> + </div> + </b-navbar-item> + </template> + </b-navbar> +</template> + +<script> +import { User } from "@/model/User"; +import { LoginService } from "@/services/LoginService"; +import { Component, Vue } from "vue-property-decorator"; + +@Component({ + components: {}, +}) +export default class MenuView extends Vue { + loginService = LoginService.INSTANCE; + + loggedUser = new User(); + + created() { + this.init(); + } + + async init() { + this.loggedUser = await this.loginService.getLoggedUser(); + } + + logout() { + this.loginService.logout(); + } +} +</script> + +<style lang="scss" scoped> +.menu-view { + background-color: $primary; + height: $menu-height; + + .navbar-item { + flex: 1 1 auto; + font-weight: bold; + font-size: 18px; + color: $light-text; + height: 100%; + padding-left: 10px; + padding-right: 10px; + justify-content: center; + + &.router-link-exact-active { + color: white; + font-size: 20px; + } + + &:hover { + color: $primary; + } + } + + .navbar-menu { + flex: 1 1 auto; + justify-content: flex-end; + + div.navbar-start { + justify-content: space-around; + margin: 0; + } + } +} +</style> -- GitLab From 6bc27ebaa149bfcb595a1e1c774a36daa8da0e0c Mon Sep 17 00:00:00 2001 From: Brendan Le Ny <bleny@codelutin.com> Date: Fri, 30 Apr 2021 10:25:06 +0200 Subject: [PATCH 06/12] =?UTF-8?q?Autorise=20"DELETE"=20comme=20verbe=20dan?= =?UTF-8?q?s=20les=20CORS=20(n=C3=A9cessaire=20pour=20/logout)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/fr/inra/oresing/OreSiNg.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/fr/inra/oresing/OreSiNg.java b/src/main/java/fr/inra/oresing/OreSiNg.java index f216a7bfb..93488ab2d 100644 --- a/src/main/java/fr/inra/oresing/OreSiNg.java +++ b/src/main/java/fr/inra/oresing/OreSiNg.java @@ -49,6 +49,7 @@ public class OreSiNg implements WebMvcConfigurer { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedOrigins("http://localhost:8080") + .allowedMethods("POST", "PUT", "GET", "DELETE") .allowCredentials(true); } -- GitLab From 777ef412a0976d75b480f00dde22068968b94e57 Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Fri, 30 Apr 2021 11:44:31 +0200 Subject: [PATCH 07/12] =?UTF-8?q?Si=20utilisateur=20d=C3=A9j=C3=A0=20conne?= =?UTF-8?q?ct=C3=A9;=20pas=20de=20login.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui2/src/services/Fetcher.js | 24 ++++++++++++++++++++---- ui2/src/services/LoginService.js | 11 +++++++++++ ui2/src/views/ApplicationsView.vue | 4 +--- ui2/src/views/LoginView.vue | 2 +- ui2/src/views/common/PageView.vue | 26 +++++++++++++++++++++++--- 5 files changed, 56 insertions(+), 11 deletions(-) diff --git a/ui2/src/services/Fetcher.js b/ui2/src/services/Fetcher.js index 827c8fd03..0a35bfe2d 100644 --- a/ui2/src/services/Fetcher.js +++ b/ui2/src/services/Fetcher.js @@ -1,6 +1,14 @@ import config from "@/config"; +import { HttpStatusCodes } from "@/utils/HttpUtils"; +import { EventEmitter } from "events"; + +export const CREDENTIALS_LOST_EVENT = "credentialsLost"; + +export class Fetcher extends EventEmitter { + notifyCrendentialsLost() { + this.emit(CREDENTIALS_LOST_EVENT); + } -export class Fetcher { async post(url, data) { const formData = this.convertToFormData(data); @@ -59,15 +67,23 @@ export class Fetcher { if (response.ok) { return Promise.resolve(response); + } else if (response.status === HttpStatusCodes.UNAUTHORIZED) { + this.notifyCrendentialsLost(); } return Promise.reject({ status: response.status }); } async _handleResponse(response) { - if (response.ok) { - const text = await response.text(); - return Promise.resolve(JSON.parse(text)); + try { + if (response.ok && response.status !== HttpStatusCodes.NO_CONTENT) { + const text = await response.text(); + return Promise.resolve(JSON.parse(text)); + } else if (response.status === HttpStatusCodes.UNAUTHORIZED) { + this.notifyCrendentialsLost(); + } + } catch (error) { + console.error(error); } return Promise.reject({ status: response.status }); diff --git a/ui2/src/services/LoginService.js b/ui2/src/services/LoginService.js index 18236662e..d306bb569 100644 --- a/ui2/src/services/LoginService.js +++ b/ui2/src/services/LoginService.js @@ -3,6 +3,7 @@ import { User } from "@/model/User"; import { Fetcher } from "@/services/Fetcher.js"; const LOCAL_STORAGE_LOGGUED_USER = "loggedUser"; +export const LOGGED_OUT = "loggedOut"; export class LoginService extends Fetcher { static INSTANCE = new LoginService(); @@ -12,7 +13,17 @@ export class LoginService extends Fetcher { super(); } + notifyCrendentialsLost() { + localStorage.removeItem(LOCAL_STORAGE_LOGGUED_USER); + this.emit(LOGGED_OUT); + } + getLoggedUser() { + if (!this.loggedUser || !this.loggedUser.id) { + this.loggedUser = JSON.parse( + localStorage.getItem(LOCAL_STORAGE_LOGGUED_USER) + ); + } return this.loggedUser; } diff --git a/ui2/src/views/ApplicationsView.vue b/ui2/src/views/ApplicationsView.vue index 6d2f182a1..72d6faf90 100644 --- a/ui2/src/views/ApplicationsView.vue +++ b/ui2/src/views/ApplicationsView.vue @@ -1,6 +1,5 @@ <template> <div> - <MenuView /> <PageView> <h1 class="title main-title">{{ $t("titles.applications-page") }}</h1> {{ loggedUser.login }} @@ -12,11 +11,10 @@ import { User } from "@/model/User"; import { LoginService } from "@/services/LoginService"; import { Component, Vue } from "vue-property-decorator"; -import MenuView from "./common/MenuView.vue"; import PageView from "./common/PageView.vue"; @Component({ - components: { PageView, MenuView }, + components: { PageView }, }) export default class ApplicationsView extends Vue { loginService = LoginService.INSTANCE; diff --git a/ui2/src/views/LoginView.vue b/ui2/src/views/LoginView.vue index f32b17bee..48b073f1c 100644 --- a/ui2/src/views/LoginView.vue +++ b/ui2/src/views/LoginView.vue @@ -1,5 +1,5 @@ <template> - <PageView class="LoginView"> + <PageView class="LoginView" :noMenu="true"> <h1 class="title main-title">{{ $t("titles.login-page") }}</h1> <div class="card LoginView-card"> <b-tabs type="is-boxed"> diff --git a/ui2/src/views/common/PageView.vue b/ui2/src/views/common/PageView.vue index 02cb1887a..7c0245eb3 100644 --- a/ui2/src/views/common/PageView.vue +++ b/ui2/src/views/common/PageView.vue @@ -1,14 +1,34 @@ <template> <div class="container PageView-container"> + <MenuView v-if="!noMenu" /> <slot></slot> </div> </template> <script> -import { Component, Vue } from "vue-property-decorator"; +import { LoginService, LOGGED_OUT } from "@/services/LoginService"; +import { Component, Prop, Vue } from "vue-property-decorator"; +import MenuView from "./MenuView.vue"; -@Component -export default class PageView extends Vue {} +@Component({ + components: { MenuView }, +}) +export default class PageView extends Vue { + @Prop({ default: false }) noMenu; + + loginService = LoginService.INSTANCE; + + created() { + const loggedUser = this.loginService.getLoggedUser(); + if (!loggedUser || !loggedUser.id) { + this.$router.push("/login").catch(() => {}); + } + + this.loginService.on(LOGGED_OUT, () => { + this.$router.push("/login").catch(() => {}); + }); + } +} </script> <style lang="scss" scoped> -- GitLab From e85c16425e4842c0e0c0e99c71f7f7583a0c3dc9 Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Fri, 30 Apr 2021 11:51:26 +0200 Subject: [PATCH 08/12] =?UTF-8?q?D=C3=A9connexion:=20enl=C3=A8ve=20l'utili?= =?UTF-8?q?sateur=20du=20localStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui2/src/services/LoginService.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui2/src/services/LoginService.js b/ui2/src/services/LoginService.js index d306bb569..18cc64ec1 100644 --- a/ui2/src/services/LoginService.js +++ b/ui2/src/services/LoginService.js @@ -43,7 +43,8 @@ export class LoginService extends Fetcher { return Promise.resolve(response); } - logout() { - return this.delete("logout"); + async logout() { + await this.delete("logout"); + this.notifyCrendentialsLost(); } } -- GitLab From aecab691673196cfe9fa7ba6413750d14355166e Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Fri, 30 Apr 2021 11:53:09 +0200 Subject: [PATCH 09/12] =?UTF-8?q?:lipstick:=20=C3=89largissement=20du=20me?= =?UTF-8?q?nu.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui2/src/views/common/PageView.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui2/src/views/common/PageView.vue b/ui2/src/views/common/PageView.vue index 7c0245eb3..74524dbb8 100644 --- a/ui2/src/views/common/PageView.vue +++ b/ui2/src/views/common/PageView.vue @@ -1,7 +1,9 @@ <template> - <div class="container PageView-container"> + <div> <MenuView v-if="!noMenu" /> - <slot></slot> + <div class="container PageView-container"> + <slot></slot> + </div> </div> </template> -- GitLab From 0b6e25dce6b075e38fda6c91bae32695e863bff1 Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Fri, 30 Apr 2021 12:42:37 +0200 Subject: [PATCH 10/12] Centre le login sur la page. --- ui2/src/views/LoginView.vue | 8 +++++++- ui2/src/views/ReferencesView.vue | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ui2/src/views/LoginView.vue b/ui2/src/views/LoginView.vue index 48b073f1c..b39d6cb12 100644 --- a/ui2/src/views/LoginView.vue +++ b/ui2/src/views/LoginView.vue @@ -22,12 +22,18 @@ import PageView from "./common/PageView.vue"; export default class LoginView extends Vue {} </script> -<style lang="scss" scoped> +<style lang="scss"> .LoginView { display: flex; flex-direction: column; align-items: center; + .PageView-container { + display: flex; + flex-direction: column; + align-items: center; + } + .LoginView-card { width: 70%; } diff --git a/ui2/src/views/ReferencesView.vue b/ui2/src/views/ReferencesView.vue index f7e249c3d..2ead19448 100644 --- a/ui2/src/views/ReferencesView.vue +++ b/ui2/src/views/ReferencesView.vue @@ -1,6 +1,5 @@ <template> <div> - <MenuView /> <PageView class="LoginView"> <h1 class="title main-title">{{ $t("titles.references-page") }}</h1> {{ loggedUser.login }} @@ -12,11 +11,10 @@ import { User } from "@/model/User"; import { LoginService } from "@/services/LoginService"; import { Component, Vue } from "vue-property-decorator"; -import MenuView from "./common/MenuView.vue"; import PageView from "./common/PageView.vue"; @Component({ - components: { PageView, MenuView }, + components: { PageView }, }) export default class ReferencesView extends Vue { loginService = LoginService.INSTANCE; -- GitLab From f1f91042f6b0ea3eef48afbc21a55e2fd516b853 Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Fri, 30 Apr 2021 12:55:13 +0200 Subject: [PATCH 11/12] =?UTF-8?q?=C3=89tends=20la=20taille=20du=20menu.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui2/src/views/ReferencesView.vue | 2 +- ui2/src/views/common/MenuView.vue | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ui2/src/views/ReferencesView.vue b/ui2/src/views/ReferencesView.vue index 2ead19448..1de6e0bf2 100644 --- a/ui2/src/views/ReferencesView.vue +++ b/ui2/src/views/ReferencesView.vue @@ -1,6 +1,6 @@ <template> <div> - <PageView class="LoginView"> + <PageView> <h1 class="title main-title">{{ $t("titles.references-page") }}</h1> {{ loggedUser.login }} </PageView> diff --git a/ui2/src/views/common/MenuView.vue b/ui2/src/views/common/MenuView.vue index 99ed5c656..a6c9516f4 100644 --- a/ui2/src/views/common/MenuView.vue +++ b/ui2/src/views/common/MenuView.vue @@ -52,6 +52,7 @@ export default class MenuView extends Vue { .menu-view { background-color: $primary; height: $menu-height; + width: 100%; .navbar-item { flex: 1 1 auto; -- GitLab From ab6c219419d1b5ff29ec9cceafb0bfdf024001be Mon Sep 17 00:00:00 2001 From: Aurore Lecointe <lecointe@codelutin.com> Date: Tue, 4 May 2021 17:28:28 +0200 Subject: [PATCH 12/12] =?UTF-8?q?Refactoring=20suite=20=C3=A0=20une=20revu?= =?UTF-8?q?e=20de=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui2/src/locales/fr.json | 3 +-- ui2/src/services/Fetcher.js | 14 ++++---------- ui2/src/services/LoginService.js | 3 +-- .../services/validation/vee-validation-rules.js | 7 +------ ui2/src/views/LoginView.vue | 2 +- ui2/src/views/common/PageView.vue | 10 +++------- 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/ui2/src/locales/fr.json b/ui2/src/locales/fr.json index 473d57694..f0f999445 100644 --- a/ui2/src/locales/fr.json +++ b/ui2/src/locales/fr.json @@ -16,8 +16,7 @@ "validation": { "obligatoire": "Obligatoire", "facultatif": "Facultatif", - "invalid-required": "Merci de remplir le champ", - "invalid-email": "Merci de renseigner un email valide" + "invalid-required": "Merci de remplir le champ" }, "alert": { "cancel": "Annuler", diff --git a/ui2/src/services/Fetcher.js b/ui2/src/services/Fetcher.js index 0a35bfe2d..14117b5bd 100644 --- a/ui2/src/services/Fetcher.js +++ b/ui2/src/services/Fetcher.js @@ -1,14 +1,7 @@ import config from "@/config"; import { HttpStatusCodes } from "@/utils/HttpUtils"; -import { EventEmitter } from "events"; - -export const CREDENTIALS_LOST_EVENT = "credentialsLost"; - -export class Fetcher extends EventEmitter { - notifyCrendentialsLost() { - this.emit(CREDENTIALS_LOST_EVENT); - } +export class Fetcher { async post(url, data) { const formData = this.convertToFormData(data); @@ -77,13 +70,14 @@ export class Fetcher extends EventEmitter { async _handleResponse(response) { try { if (response.ok && response.status !== HttpStatusCodes.NO_CONTENT) { - const text = await response.text(); - return Promise.resolve(JSON.parse(text)); + const text = await response.json(); + return Promise.resolve(text); } else if (response.status === HttpStatusCodes.UNAUTHORIZED) { this.notifyCrendentialsLost(); } } catch (error) { console.error(error); + throw error; } return Promise.reject({ status: response.status }); diff --git a/ui2/src/services/LoginService.js b/ui2/src/services/LoginService.js index 18cc64ec1..e32f45316 100644 --- a/ui2/src/services/LoginService.js +++ b/ui2/src/services/LoginService.js @@ -3,7 +3,6 @@ import { User } from "@/model/User"; import { Fetcher } from "@/services/Fetcher.js"; const LOCAL_STORAGE_LOGGUED_USER = "loggedUser"; -export const LOGGED_OUT = "loggedOut"; export class LoginService extends Fetcher { static INSTANCE = new LoginService(); @@ -15,7 +14,7 @@ export class LoginService extends Fetcher { notifyCrendentialsLost() { localStorage.removeItem(LOCAL_STORAGE_LOGGUED_USER); - this.emit(LOGGED_OUT); + app.$router.push("/login").catch(() => {}); } getLoggedUser() { diff --git a/ui2/src/services/validation/vee-validation-rules.js b/ui2/src/services/validation/vee-validation-rules.js index decdfd6ad..5233349ff 100644 --- a/ui2/src/services/validation/vee-validation-rules.js +++ b/ui2/src/services/validation/vee-validation-rules.js @@ -1,5 +1,5 @@ import i18n from "@/i18n"; -import { email, required } from "vee-validate/dist/rules"; +import { required } from "vee-validate/dist/rules"; import { extend } from "vee-validate"; // See https://logaretm.github.io/vee-validate/guide/rules.html // For list of all availables rules @@ -8,8 +8,3 @@ extend("required", { ...required, message: i18n.t("validation.invalid-required"), }); - -extend("email", { - ...email, - message: i18n.t("validation.invalid-email"), -}); diff --git a/ui2/src/views/LoginView.vue b/ui2/src/views/LoginView.vue index b39d6cb12..9530262eb 100644 --- a/ui2/src/views/LoginView.vue +++ b/ui2/src/views/LoginView.vue @@ -1,5 +1,5 @@ <template> - <PageView class="LoginView" :noMenu="true"> + <PageView class="LoginView" :hasMenu="false"> <h1 class="title main-title">{{ $t("titles.login-page") }}</h1> <div class="card LoginView-card"> <b-tabs type="is-boxed"> diff --git a/ui2/src/views/common/PageView.vue b/ui2/src/views/common/PageView.vue index 74524dbb8..d5c5ff80f 100644 --- a/ui2/src/views/common/PageView.vue +++ b/ui2/src/views/common/PageView.vue @@ -1,6 +1,6 @@ <template> <div> - <MenuView v-if="!noMenu" /> + <MenuView v-if="hasMenu" /> <div class="container PageView-container"> <slot></slot> </div> @@ -8,7 +8,7 @@ </template> <script> -import { LoginService, LOGGED_OUT } from "@/services/LoginService"; +import { LoginService } from "@/services/LoginService"; import { Component, Prop, Vue } from "vue-property-decorator"; import MenuView from "./MenuView.vue"; @@ -16,7 +16,7 @@ import MenuView from "./MenuView.vue"; components: { MenuView }, }) export default class PageView extends Vue { - @Prop({ default: false }) noMenu; + @Prop({ default: true }) hasMenu; loginService = LoginService.INSTANCE; @@ -25,10 +25,6 @@ export default class PageView extends Vue { if (!loggedUser || !loggedUser.id) { this.$router.push("/login").catch(() => {}); } - - this.loginService.on(LOGGED_OUT, () => { - this.$router.push("/login").catch(() => {}); - }); } } </script> -- GitLab