umwd-components 0.1.441 → 0.1.443
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/auth/PasswordResetForm.js +1 -1
- package/dist/src/data/actions/auth-actions.js +1 -1
- package/dist/src/data/services/auth-service.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/auth/PasswordResetForm.tsx +8 -3
- package/src/data/actions/auth-actions.ts +3 -0
- package/src/data/services/auth-service.ts +1 -0
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as r,__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import t from"react";import{useFormState as o}from"react-dom";import{resetPasswordAction as a}from"../../data/actions/auth-actions.js";import i from"@mui/material/Card";import
|
|
7
|
+
import{__read as r,__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import t from"react";import{useFormState as o}from"react-dom";import{resetPasswordAction as a}from"../../data/actions/auth-actions.js";import i from"@mui/material/Card";import l from"@mui/material/CardContent";import m from"@mui/material/CardActions";import n from"@mui/material/TextField";import s from"@mui/material/Stack";import d from"@mui/material/Container";import u from"@mui/material/Typography";import{SubmitButton as p}from"../SubmitButton.js";import{StrapiErrors as v}from"../StrapiErrors.js";import{useSearchParams as c}from"next/navigation";var E={zodErrors:null,strapiErrors:null,data:null,message:null};function f(f){var w,x,C,g,b=f.data,h=b.title,y=void 0===h?"Reset Password":h,z=b.subtitle,T=void 0===z?"Enter your new password":z,j=b.maxWidth,P=void 0===j?"sm":j,R=b.sx,S=void 0===R?{}:R,N=r(o(a,E),2),W=N[0],k=N[1],A=c().get("code");return t.createElement(d,{maxWidth:P||"sm",sx:e({my:1},S)},t.createElement("form",{action:k},t.createElement(i,null,t.createElement(l,null,null!==A&&t.createElement("input",{type:"hidden",name:"code",value:A}),t.createElement(u,{variant:"h5"},y),t.createElement(u,{variant:"subtitle1"},T),t.createElement(s,{spacing:2,sx:{mt:2}},t.createElement(n,{id:"password",name:"password",label:"New Password",type:"password",variant:"outlined",error:null!=(null===(w=null==W?void 0:W.zodErrors)||void 0===w?void 0:w.password),helperText:null===(x=null==W?void 0:W.zodErrors)||void 0===x?void 0:x.password}),t.createElement(n,{id:"passwordConfirmation",name:"passwordConfirmation",label:"Confirm New Password",type:"password",variant:"outlined",error:null!=(null===(C=null==W?void 0:W.zodErrors)||void 0===C?void 0:C.passwordConfirmation),helperText:null===(g=null==W?void 0:W.zodErrors)||void 0===g?void 0:g.passwordConfirmation}))),t.createElement(m,null,t.createElement(p,{text:"Reset Password",loadingText:"Resetting..."}),t.createElement(v,{error:null==W?void 0:W.strapiErrors}))),W.message&&t.createElement(u,{sx:{pt:2},variant:"body2"},W.message)))}export{f as default};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as e,__generator as r,__assign as s}from"../../../node_modules/tslib/tslib.es6.js";import{z as a}from"zod";import{cookies as t}from"next/headers";import{redirect as o}from"next/navigation";import{registerUserService as n,loginUserService as i,forgotPasswordService as l,resetPasswordService as d}from"../services/auth-service.js";var m,u={maxAge:604800,path:"/",domain:null!==(m=process.env.HOST)&&void 0!==m?m:"localhost",httpOnly:!0,secure:"production"===process.env.NODE_ENV},c=a.object({username:a.string().min(3).max(20,{message:"Username must be between 3 and 20 characters"}),password:a.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),email:a.string().email({message:"Please enter a valid email address"}),redirect:a.string().optional()});function g(a,i){return e(this,void 0,void 0,(function(){var e,l,d,m,g,v;return r(this,(function(r){switch(r.label){case 0:return(e=c.safeParse({username:i.get("username"),password:i.get("password"),email:i.get("email")})).success?[4,n(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,strapiErrors:null,message:"Missing Fields. Failed to Register."})];case 1:return!(l=r.sent())||l.error?[2,s(s({},a),{strapiErrors:(null===(m=null==l?void 0:l.error)||void 0===m?void 0:m.message)||null,zodErrors:null,message:(null==l?void 0:l.error)?"Failed to Register.":"Ops! Something went wrong. Please try again."})]:(d=null!==(v=null===(g=i.get("redirect"))||void 0===g?void 0:g.toString())&&void 0!==v?v:null,t().set("jwt",l.jwt,u),o(d||"/dashboard"),[2])}}))}))}var v=a.object({identifier:a.string().min(3,{message:"Identifier must have at least 3 or more characters"}).max(20,{message:"Please enter a valid username or email address"}),password:a.string().min(6,{message:"Password must have at least 6 or more characters"}).max(100,{message:"Password must be between 6 and 100 characters"}),redirect:a.string().optional()});function w(a,n){return e(this,void 0,void 0,(function(){var e,l,d,m,c,g,w;return r(this,(function(r){switch(r.label){case 0:return(e=v.safeParse({identifier:n.get("identifier"),password:n.get("password")})).success?[4,i(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,message:"Missing Fields. Failed to Login."})];case 1:return!(l=r.sent())||l.error?(console.log("Login Error:",l),[2,s(s({},a),{strapiErrors:(null===(c=null==l?void 0:l.error)||void 0===c?void 0:c.message)||null,zodErrors:null,message:(null==l?void 0:l.error)?"Failed to Login.":"Ops! Something went wrong. Please try again."})]):(t().set("jwt",l.jwt,u),d=null!==(w=null===(g=n.get("redirect"))||void 0===g?void 0:g.toString())&&void 0!==w?w:null,m="".concat(d||"/dashboard","?login=success"),o(m),[2])}}))}))}var f=a.object({email:a.string().email({message:"Please enter a valid email address"})});function p(a,t){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return(e=f.safeParse({email:t.get("email")})).success?[4,l(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,message:"Invalid email address."})];case 1:return o=r.sent(),console.log("Forgot Password Response:",o),o?o.error?[2,s(s({},a),{strapiErrors:o.error,zodErrors:null,message:"Failed to send reset email."})]:[2,s(s({},a),{message:"Password reset email sent successfully."})]:[2,s(s({},a),{strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}var h=a.object({password:a.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),passwordConfirmation:a.string().min(6).max(100,{message:"Password confirmation must be between 6 and 100 characters"}),code:a.string()});function E(a,t){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return
|
|
7
|
+
import{__awaiter as e,__generator as r,__assign as s}from"../../../node_modules/tslib/tslib.es6.js";import{z as a}from"zod";import{cookies as t}from"next/headers";import{redirect as o}from"next/navigation";import{registerUserService as n,loginUserService as i,forgotPasswordService as l,resetPasswordService as d}from"../services/auth-service.js";var m,u={maxAge:604800,path:"/",domain:null!==(m=process.env.HOST)&&void 0!==m?m:"localhost",httpOnly:!0,secure:"production"===process.env.NODE_ENV},c=a.object({username:a.string().min(3).max(20,{message:"Username must be between 3 and 20 characters"}),password:a.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),email:a.string().email({message:"Please enter a valid email address"}),redirect:a.string().optional()});function g(a,i){return e(this,void 0,void 0,(function(){var e,l,d,m,g,v;return r(this,(function(r){switch(r.label){case 0:return(e=c.safeParse({username:i.get("username"),password:i.get("password"),email:i.get("email")})).success?[4,n(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,strapiErrors:null,message:"Missing Fields. Failed to Register."})];case 1:return!(l=r.sent())||l.error?[2,s(s({},a),{strapiErrors:(null===(m=null==l?void 0:l.error)||void 0===m?void 0:m.message)||null,zodErrors:null,message:(null==l?void 0:l.error)?"Failed to Register.":"Ops! Something went wrong. Please try again."})]:(d=null!==(v=null===(g=i.get("redirect"))||void 0===g?void 0:g.toString())&&void 0!==v?v:null,t().set("jwt",l.jwt,u),o(d||"/dashboard"),[2])}}))}))}var v=a.object({identifier:a.string().min(3,{message:"Identifier must have at least 3 or more characters"}).max(20,{message:"Please enter a valid username or email address"}),password:a.string().min(6,{message:"Password must have at least 6 or more characters"}).max(100,{message:"Password must be between 6 and 100 characters"}),redirect:a.string().optional()});function w(a,n){return e(this,void 0,void 0,(function(){var e,l,d,m,c,g,w;return r(this,(function(r){switch(r.label){case 0:return(e=v.safeParse({identifier:n.get("identifier"),password:n.get("password")})).success?[4,i(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,message:"Missing Fields. Failed to Login."})];case 1:return!(l=r.sent())||l.error?(console.log("Login Error:",l),[2,s(s({},a),{strapiErrors:(null===(c=null==l?void 0:l.error)||void 0===c?void 0:c.message)||null,zodErrors:null,message:(null==l?void 0:l.error)?"Failed to Login.":"Ops! Something went wrong. Please try again."})]):(t().set("jwt",l.jwt,u),d=null!==(w=null===(g=n.get("redirect"))||void 0===g?void 0:g.toString())&&void 0!==w?w:null,m="".concat(d||"/dashboard","?login=success"),o(m),[2])}}))}))}var f=a.object({email:a.string().email({message:"Please enter a valid email address"})});function p(a,t){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return(e=f.safeParse({email:t.get("email")})).success?[4,l(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,message:"Invalid email address."})];case 1:return o=r.sent(),console.log("Forgot Password Response:",o),o?o.error?[2,s(s({},a),{strapiErrors:o.error,zodErrors:null,message:"Failed to send reset email."})]:[2,s(s({},a),{message:"Password reset email sent successfully."})]:[2,s(s({},a),{strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}var h=a.object({password:a.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),passwordConfirmation:a.string().min(6).max(100,{message:"Password confirmation must be between 6 and 100 characters"}),code:a.string()});function E(a,t){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return e=h.safeParse({password:t.get("password"),passwordConfirmation:t.get("passwordConfirmation"),code:t.get("code")}),console.log("validatedFields",e),e.success?[4,d(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,message:"Invalid input."})];case 1:return o=r.sent(),console.log("Reset Password Response:",o),o?o.error?[2,s(s({},a),{strapiErrors:o.error,zodErrors:null,message:"Failed to reset password."})]:[2,s(s({},a),{message:"Password reset successfully."})]:[2,s(s({},a),{strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}function b(){return e(this,void 0,void 0,(function(){return r(this,(function(e){return t().set("jwt","",s(s({},u),{maxAge:0})),o("/"),[2]}))}))}export{p as forgotPasswordAction,w as loginUserAction,b as logoutAction,g as registerUserAction,E as resetPasswordAction};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as e,__generator as r,__assign as n}from"../../../node_modules/tslib/tslib.es6.js";import{getStrapiURL as o}from"../../lib/utils.js";var s=o();function t(o){return e(this,void 0,void 0,(function(){var e,t,c,a;return r(this,(function(r){switch(r.label){case 0:e=new URL("/api/auth/local/register",s),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n({},o)),cache:"no-cache"})];case 2:return(t=r.sent()).ok?[3,4]:[4,t.json()];case 3:return c=r.sent(),console.error("Register Service Error:",c),[2,{error:c}];case 4:return[2,t.json()];case 5:return a=r.sent(),console.error("Registration Service Error:",a),[2,{error:a instanceof Error?a.message:"Unknown error"}];case 6:return[2]}}))}))}function c(o){return e(this,void 0,void 0,(function(){var e,t,c,a;return r(this,(function(r){switch(r.label){case 0:e=new URL("/api/auth/local",s),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n({},o)),cache:"no-cache"})];case 2:return(t=r.sent()).ok?[3,4]:[4,t.json()];case 3:return c=r.sent(),console.log("Login Error:",c),[2,{error:c}];case 4:return[2,t.json()];case 5:return a=r.sent(),console.error("Login Service Error:",a),[2,{error:a instanceof Error?a.message:"Unknown error"}];case 6:return[2]}}))}))}function a(n){return e(this,void 0,void 0,(function(){var e,o,t,c;return r(this,(function(r){switch(r.label){case 0:e=new URL("/api/auth/forgot-password",s),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})];case 2:return o=r.sent(),console.log("Forgot Password Service Response:",o),[4,o.json()];case 3:return t=r.sent(),console.log("Forgot Password Service Result:",t),[2,t];case 4:return c=r.sent(),console.error("Error in forgotPasswordService:",c),[2,null];case 5:return[2]}}))}))}function i(n){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:e=new URL("/api/auth/reset-password",s),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})];case 2:return[4,r.sent().json()];case 3:return
|
|
7
|
+
import{__awaiter as e,__generator as r,__assign as n}from"../../../node_modules/tslib/tslib.es6.js";import{getStrapiURL as o}from"../../lib/utils.js";var s=o();function t(o){return e(this,void 0,void 0,(function(){var e,t,c,a;return r(this,(function(r){switch(r.label){case 0:e=new URL("/api/auth/local/register",s),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n({},o)),cache:"no-cache"})];case 2:return(t=r.sent()).ok?[3,4]:[4,t.json()];case 3:return c=r.sent(),console.error("Register Service Error:",c),[2,{error:c}];case 4:return[2,t.json()];case 5:return a=r.sent(),console.error("Registration Service Error:",a),[2,{error:a instanceof Error?a.message:"Unknown error"}];case 6:return[2]}}))}))}function c(o){return e(this,void 0,void 0,(function(){var e,t,c,a;return r(this,(function(r){switch(r.label){case 0:e=new URL("/api/auth/local",s),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n({},o)),cache:"no-cache"})];case 2:return(t=r.sent()).ok?[3,4]:[4,t.json()];case 3:return c=r.sent(),console.log("Login Error:",c),[2,{error:c}];case 4:return[2,t.json()];case 5:return a=r.sent(),console.error("Login Service Error:",a),[2,{error:a instanceof Error?a.message:"Unknown error"}];case 6:return[2]}}))}))}function a(n){return e(this,void 0,void 0,(function(){var e,o,t,c;return r(this,(function(r){switch(r.label){case 0:e=new URL("/api/auth/forgot-password",s),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})];case 2:return o=r.sent(),console.log("Forgot Password Service Response:",o),[4,o.json()];case 3:return t=r.sent(),console.log("Forgot Password Service Result:",t),[2,t];case 4:return c=r.sent(),console.error("Error in forgotPasswordService:",c),[2,null];case 5:return[2]}}))}))}function i(n){return e(this,void 0,void 0,(function(){var e,o,t;return r(this,(function(r){switch(r.label){case 0:e=new URL("/api/auth/reset-password",s),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})];case 2:return[4,r.sent().json()];case 3:return o=r.sent(),console.log("Reset Password Service Result:",o),[2,o];case 4:return t=r.sent(),console.error("Error in resetPasswordService:",t),[2,null];case 5:return[2]}}))}))}export{a as forgotPasswordService,c as loginUserService,t as registerUserService,i as resetPasswordService};
|