2 lines
4.4 KiB
JavaScript
2 lines
4.4 KiB
JavaScript
import{a as E}from"./chunk-SMVD5LRJ.js";import{c as N,d as W,e as I,f as A,g as D,h as L,p as T,r as q,t as V}from"./chunk-UDFQV3WY.js";import{e as S}from"./chunk-ZEULGWAI.js";import{a as _}from"./chunk-MBEC6LK4.js";import{Bb as v,Eb as s,Fa as a,Fb as w,Gb as y,Hc as M,Jb as p,Kb as c,Lb as g,M as m,Ta as h,Ya as b,ca as u,jb as f,kb as e,lb as n,rb as P,rc as C,sb as x}from"./chunk-TVKQFRWX.js";import"./chunk-DAQOROHW.js";function R(d,o){if(d&1&&(e(0,"div",16),s(1),n()),d&2){let i=x();v("bg-green-50",i.success())("text-green-700",i.success())("bg-red-50",!i.success())("text-red-700",!i.success()),a(),w(i.message())}}var k=class d{auth=m(E);http=m(M);router=m(S);oldPassword="";newPassword="";confirmation="";loading=u(!1);message=u("");success=u(!1);changePassword(){if(!this.isStrongPassword(this.newPassword)){this.showError("Le nouveau mot de passe ne respecte pas les crit\xE8res de s\xE9curit\xE9.");return}if(this.newPassword!==this.confirmation){this.showError("La confirmation ne correspond pas au nouveau mot de passe.");return}let o=this.auth.currentUser()?.id;o&&(this.loading.set(!0),this.message.set(""),this.http.put(`${_.apiUrl}/users/${o}/password`,{oldPassword:this.oldPassword,newPassword:this.newPassword}).subscribe({next:()=>{this.auth.clearSession(),this.router.navigate(["/auth/login"],{queryParams:{passwordChanged:"1"}})},error:i=>{this.showError(i.error?.message||"La modification du mot de passe a \xE9chou\xE9."),this.loading.set(!1)}}))}showError(o){this.success.set(!1),this.message.set(o)}isStrongPassword(o){return o.length>=10&&/[A-Z]/.test(o)&&/[a-z]/.test(o)&&/\d/.test(o)&&/[^A-Za-z0-9]/.test(o)}static \u0275fac=function(i){return new(i||d)};static \u0275cmp=h({type:d,selectors:[["app-profile"]],decls:28,vars:7,consts:[[1,"mx-auto","max-w-2xl"],[1,"mb-7"],[1,"text-sm","font-bold","uppercase","tracking-wider","text-primary-700"],[1,"mt-2","text-3xl","font-bold"],[1,"mt-2","text-slate-500"],[1,"space-y-5","rounded-2xl","border","border-slate-100","bg-white","p-7","shadow-card",3,"ngSubmit"],[1,"text-xl","font-bold"],["class","rounded-xl p-4 text-sm",3,"bg-green-50","text-green-700","bg-red-50","text-red-700",4,"ngIf"],["for","oldPassword",1,"block","text-sm","font-semibold","text-slate-700"],["id","oldPassword","type","password","name","oldPassword","required","","autocomplete","current-password",1,"input","mt-2","w-full",3,"ngModelChange","ngModel"],["for","newPassword",1,"block","text-sm","font-semibold","text-slate-700"],["id","newPassword","type","password","name","newPassword","required","","minlength","10","autocomplete","new-password",1,"input","mt-2","w-full",3,"ngModelChange","ngModel"],["for","confirmation",1,"block","text-sm","font-semibold","text-slate-700"],["id","confirmation","type","password","name","confirmation","required","","minlength","10","autocomplete","new-password",1,"input","mt-2","w-full",3,"ngModelChange","ngModel"],[1,"rounded-xl","bg-slate-50","p-4","text-xs","leading-5","text-slate-600"],["type","submit",1,"btn-primary","disabled:opacity-60",3,"disabled"],[1,"rounded-xl","p-4","text-sm"]],template:function(i,t){if(i&1&&(e(0,"div",0)(1,"div",1)(2,"p",2),s(3,"S\xE9curit\xE9"),n(),e(4,"h1",3),s(5,"Mon profil"),n(),e(6,"p",4),s(7),n()(),e(8,"form",5),P("ngSubmit",function(){return t.changePassword()}),e(9,"h2",6),s(10,"Changer mon mot de passe"),n(),b(11,R,2,9,"div",7),e(12,"div")(13,"label",8),s(14,"Mot de passe actuel"),n(),e(15,"input",9),g("ngModelChange",function(r){return c(t.oldPassword,r)||(t.oldPassword=r),r}),n()(),e(16,"div")(17,"label",10),s(18,"Nouveau mot de passe"),n(),e(19,"input",11),g("ngModelChange",function(r){return c(t.newPassword,r)||(t.newPassword=r),r}),n()(),e(20,"div")(21,"label",12),s(22,"Confirmer le nouveau mot de passe"),n(),e(23,"input",13),g("ngModelChange",function(r){return c(t.confirmation,r)||(t.confirmation=r),r}),n()(),e(24,"p",14),s(25,"Au moins 10 caract\xE8res avec une majuscule, une minuscule, un chiffre et un caract\xE8re sp\xE9cial. Vous serez ensuite invit\xE9 \xE0 vous reconnecter."),n(),e(26,"button",15),s(27),n()()()),i&2){let l;a(7),y("Compte connect\xE9 : ",(l=t.auth.currentUser())==null?null:l.username),a(4),f("ngIf",t.message()),a(4),p("ngModel",t.oldPassword),a(4),p("ngModel",t.newPassword),a(4),p("ngModel",t.confirmation),a(3),f("disabled",t.loading()),a(),w(t.loading()?"Modification\u2026":"Modifier le mot de passe")}},dependencies:[V,L,N,W,I,T,q,D,A,C],encapsulation:2})};export{k as ProfileComponent};
|