Better login
This commit is contained in:
		| @ -24,7 +24,6 @@ public class AuthenticatorService { | |||||||
|         return tokenService.getUserFromToken(token); |         return tokenService.getUserFromToken(token); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     public String login(String identifier, String password, Date expirationDate){ |     public String login(String identifier, String password, Date expirationDate){ | ||||||
|         User user = userService.getUser(identifier); |         User user = userService.getUser(identifier); | ||||||
|         if (user == null){return null;} |         if (user == null){return null;} | ||||||
|  | |||||||
| @ -28,6 +28,7 @@ public class InscriptionService { | |||||||
|     private final MinervalRepository minervalRepository; |     private final MinervalRepository minervalRepository; | ||||||
|     private final ExternalCurriculumRepository externalCurriculumRepository; |     private final ExternalCurriculumRepository externalCurriculumRepository; | ||||||
|     private final UserService userService; |     private final UserService userService; | ||||||
|  |  | ||||||
|     public InscriptionService(InscriptionRepository inscriptionRepo, UserRepository userRepo, UserCurriculumRepository userCurriculumRepo, CurriculumRepository curriculumRepo, MinervalRepository minervalRepository, ExternalCurriculumRepository externalCurriculumRepository, UserService userService){ |     public InscriptionService(InscriptionRepository inscriptionRepo, UserRepository userRepo, UserCurriculumRepository userCurriculumRepo, CurriculumRepository curriculumRepo, MinervalRepository minervalRepository, ExternalCurriculumRepository externalCurriculumRepository, UserService userService){ | ||||||
|         this.inscriptionRepo = inscriptionRepo; |         this.inscriptionRepo = inscriptionRepo; | ||||||
|         this.userRepo = userRepo; |         this.userRepo = userRepo; | ||||||
|  | |||||||
| @ -117,6 +117,7 @@ public class ProtectionService { | |||||||
|         toReturn.put("identityCard", inscriptionRequest.getIdentityCard()); |         toReturn.put("identityCard", inscriptionRequest.getIdentityCard()); | ||||||
|         toReturn.put("submissionDate", inscriptionRequest.getSubmissionDate()); |         toReturn.put("submissionDate", inscriptionRequest.getSubmissionDate()); | ||||||
|         toReturn.put("equivalenceState", inscriptionRequest.getEquivalenceState()); |         toReturn.put("equivalenceState", inscriptionRequest.getEquivalenceState()); | ||||||
|  |         toReturn.put("admissionDocUrl", inscriptionRequest.getAdmissionDocUrl()); | ||||||
|         return toReturn; |         return toReturn; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -58,17 +58,17 @@ async function refreshCursus(){ | |||||||
|             {{ i18n("login.guest.country") }} : {{request.country}} |             {{ i18n("login.guest.country") }} : {{request.country}} | ||||||
|           </div> |           </div> | ||||||
|           <div> |           <div> | ||||||
|             {{ i18n("login.guest.birthday") }} : {{request.birthDate}} |             {{ i18n("login.guest.birthday") }} : {{request.birthDate.slice(0,10)}} | ||||||
|           </div> |           </div> | ||||||
|           <div> |           <div> | ||||||
|             {{ i18n("WantedCursus") }} : BAB {{cursus.year}} {{cursus.option}} |             {{ i18n("WantedCursus") }} : BAB {{cursus.year}} {{cursus.option}} | ||||||
|           </div> |           </div> | ||||||
|           <div style="margin-top: 3%"> |           <div style="margin-top: 3%"> | ||||||
|             <button><a :href="request.identityCard">{{ i18n("dlidentitycard") }}</a></button> |             <button><a :href="request.identityCard">{{ i18n("dlidentitycard") }}</a></button> | ||||||
|             <button v-if="request.admissionDocUrl != null"><a :href="request.admissionDocUrl">{{ i18n("dladmissiondoc") }}</a></button> |             <button style="margin-left: 3%" v-if="request.admissionDocUrl != null"><a :href="request.admissionDocUrl">{{ i18n("dladmissiondoc") }}</a></button> | ||||||
|           </div> |           </div> | ||||||
|           <div v-if="externalCurriculum.length !== 0"> |           <div> | ||||||
|             <button style="background-color:rgb(105,05,105);margin-top: 3%" @click="list=!list" v-if="(user.role == 'Teacher' || user.role == 'Admin')">{{ i18n("seeextcur") }}</button> |             <button style="background-color:rgb(105,05,105);margin-top: 3%" @click="list=!list" v-if="(user.role === 'Teacher' || user.role === 'Admin')">{{ i18n("seeextcur") }}</button> | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ | |||||||
|     surname:null, |     surname:null, | ||||||
|     firstname:null, |     firstname:null, | ||||||
|     password:null, |     password:null, | ||||||
|     birthday:null, |     birthday:"1990-01-01", | ||||||
|     email:null, |     email:null, | ||||||
|     address:null, |     address:null, | ||||||
|     country:null, |     country:null, | ||||||
| @ -36,7 +36,7 @@ | |||||||
|   const ppData = ref({}) |   const ppData = ref({}) | ||||||
|   const idcardfile = ref({}) |   const idcardfile = ref({}) | ||||||
|   const justifcardfile = ref({}) |   const justifcardfile = ref({}) | ||||||
|  |   const allfileshere = ref(0) | ||||||
|   const curricula= await getAllCurriculums(); |   const curricula= await getAllCurriculums(); | ||||||
|    |    | ||||||
|   function goBackHome(){ |   function goBackHome(){ | ||||||
| @ -73,7 +73,13 @@ | |||||||
|     //We upload the two files and we get their paths on the server |     //We upload the two files and we get their paths on the server | ||||||
|     const identityCardFile = await uploadFile(idcardfile.value, "IdentityCard") |     const identityCardFile = await uploadFile(idcardfile.value, "IdentityCard") | ||||||
|     const justifFile = ref(null) |     const justifFile = ref(null) | ||||||
|     const profilepic = await uploadProfilePicture(ppData.value) |  | ||||||
|  |  | ||||||
|  |     const profilepic = ref(null) | ||||||
|  |     if (imageSaved){ | ||||||
|  |       profilepic.value = await uploadProfilePicture(ppData.value) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     if (curricula[outputs.curriculum-1].requireCertificate){ |     if (curricula[outputs.curriculum-1].requireCertificate){ | ||||||
|       justifFile.value = await uploadFile(justifcardfile.value, "JustificationDocument") |       justifFile.value = await uploadFile(justifcardfile.value, "JustificationDocument") | ||||||
| @ -86,7 +92,7 @@ | |||||||
|       justif = null |       justif = null | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const val = await register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, profilepic.url, identityCardFile.url, new Date(), outputs.equivalenceState, justif); |     const val = await register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, profilepic.value.url, identityCardFile.url, new Date(), outputs.equivalenceState, justif); | ||||||
|  |  | ||||||
|     for (let item in externalCurrTab.value){ |     for (let item in externalCurrTab.value){ | ||||||
|       const temp = await uploadFile(externalCurrTab.value[item].justifdocUrl, "JustificationDocument") |       const temp = await uploadFile(externalCurrTab.value[item].justifdocUrl, "JustificationDocument") | ||||||
| @ -94,6 +100,13 @@ | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   function everyfilehere(){ | ||||||
|  |     if(allfileshere.value === 2 || (allfileshere.value === 1 && curricula[outputs.curriculum-1].requireCertificate === false)){ | ||||||
|  |       return true | ||||||
|  |     }else{ | ||||||
|  |       return false | ||||||
|  |     } | ||||||
|  |   } | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <template> | <template> | ||||||
| @ -138,7 +151,7 @@ | |||||||
|               </div> |               </div> | ||||||
|               <div class="inputBox"> |               <div class="inputBox"> | ||||||
|                 <p>{{i18n("login.guest.birthday")}}</p> |                 <p>{{i18n("login.guest.birthday")}}</p> | ||||||
|                 <input type="date" v-model="outputs.birthday"> |                 <input type="date" v-model="outputs.birthday" value="1990-01-05" min="1912-01-01" max="2024-01-01"> | ||||||
|               </div> |               </div> | ||||||
|               <div class="inputBox"> |               <div class="inputBox"> | ||||||
|                  <p>{{i18n("login.guest.password")}}</p> |                  <p>{{i18n("login.guest.password")}}</p> | ||||||
| @ -150,7 +163,7 @@ | |||||||
|               </div> |               </div> | ||||||
|                |                | ||||||
|               <div class="switchpage"> |               <div class="switchpage"> | ||||||
|                 <button @click="verifyInputs(outputs.password);">{{i18n("login.guest.nextpage")}}</button> |                 <button @click="verifyInputs(outputs.password);idcardfile={};justifcardfile={}">{{i18n("login.guest.nextpage")}}</button> | ||||||
|  |  | ||||||
|               </div> |               </div> | ||||||
|               <div @click="(loginPage=!loginPage) && (page=0)" class="register"> |               <div @click="(loginPage=!loginPage) && (page=0)" class="register"> | ||||||
| @ -173,13 +186,7 @@ | |||||||
|               <form class="inputBox" novalidate enctype="multipart/form-data"> |               <form class="inputBox" novalidate enctype="multipart/form-data"> | ||||||
|               	<p>{{i18n("profile.picture").toUpperCase()}}</p> |               	<p>{{i18n("profile.picture").toUpperCase()}}</p> | ||||||
|               </form> |               </form> | ||||||
|               <label class="browser"> | 				        <input  style="color:rgb(239,60,168);" type="file" name="picture" @change="ppData = $event.target.files;imageSaved=true" accept="image/*"> | ||||||
|                 {{i18n("login.guest.browse")}} |  | ||||||
| 				        <input  type="file" :disabled="imageSaved" @change="ppData = $event.target.files; imageSaved = true;" accept="image/*"> |  | ||||||
|               </label> |  | ||||||
|               <form novalidate enctype="multipart/form-data" class="inputBox"> |  | ||||||
| 				        <input type="file" @change="imageSaved = true;" accept="image/*"> |  | ||||||
|               </form> |  | ||||||
|               <div class="inputBox"> |               <div class="inputBox"> | ||||||
|                 <p>{{i18n("Curriculum").toUpperCase()}}</p>  |                 <p>{{i18n("Curriculum").toUpperCase()}}</p>  | ||||||
|                   <select v-model="outputs.curriculum"> |                   <select v-model="outputs.curriculum"> | ||||||
| @ -203,21 +210,16 @@ | |||||||
|             </div> |             </div> | ||||||
|             <div v-if="page === 2"> |             <div v-if="page === 2"> | ||||||
|               <p style="color:rgb(239,60,168);">{{i18n("login.guest.identityCard")}}</p> |               <p style="color:rgb(239,60,168);">{{i18n("login.guest.identityCard")}}</p> | ||||||
|               <label class="browser"> |                 <input style="color:rgb(239,60,168);margin-bottom: 3%" type="file" @change="idcardfile = $event.target.files;allfileshere = Math.min(allfileshere+1, 2)"> | ||||||
|                 {{i18n("login.guest.browse")}} |  | ||||||
|                 <input  type="file" @change="idcardfile = $event.target.files"> |  | ||||||
|               </label> |  | ||||||
|               <div v-if="curricula[outputs.curriculum-1].requireCertificate === true" style="margin-top: 3%; margin-bottom: 4%"> |               <div v-if="curricula[outputs.curriculum-1].requireCertificate === true" style="margin-top: 3%; margin-bottom: 4%"> | ||||||
|                 <p style="color:rgb(239,60,168);">{{ i18n("login.guest.attestationdisclaimer") }}</p> |                 <p style="color:rgb(239,60,168);">{{ i18n("login.guest.attestationdisclaimer") }}</p> | ||||||
|                 <div style="margin-top: 2%"> |                 <div style="margin-top: 2%"> | ||||||
|                   <p style="color:rgb(239,60,168);">Attestation:</p> |                   <p style="color:rgb(239,60,168);">Attestation:</p> | ||||||
|                   <label class="browser"> |                     <input style=" color:rgb(239,60,168);" type="file" @change="justifcardfile = $event.target.files;allfileshere = Math.min(allfileshere+1, 2)"> | ||||||
|                     {{i18n("login.guest.browse")}} |  | ||||||
|                     <input  type="file" @change="justifcardfile = $event.target.files"> |  | ||||||
|                   </label> |  | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|               <button @click="page++;" style="margin-top: 10%">{{i18n("login.guest.nextpage")}}</button> |               <div v-if="everyfilehere()"><button @click="page++;" style="margin-top: 10%">{{i18n("login.guest.nextpage")}}</button></div> | ||||||
|  |               <div v-else style="color: rgb(239,60,168); margin-top: 5%; margin-bottom: 5%">Please upload all the required files</div> | ||||||
|             </div> |             </div> | ||||||
|             <div v-if="page === 3"> |             <div v-if="page === 3"> | ||||||
|               <p style="color:rgb(239,60,168);margin-bottom: 5%"> |               <p style="color:rgb(239,60,168);margin-bottom: 5%"> | ||||||
| @ -320,9 +322,6 @@ input[type=submit],button,select{ | |||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| input[type=file]{ |  | ||||||
|   display:none; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| .browser{ | .browser{ | ||||||
|   display:inline-block; |   display:inline-block; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user