PageSourceSearch

https://tuforums.com/assets/SettingsSecurityPage.BVuVnkBK.js

js tuforums.com collected 2026-09-24 14:19:58 UTC 17,522 bytes, 1 lines download raw bytes

1import{e as fe,cA as me,a as b,r as P,j as e,d as pe,aG as E,bz as m}from"./index.CHvzgvcl.js";import{r as c}from"./reactRouter.DIJDf_PU.js";import{D as he}from"./DiscordIcon.BPe0K4t5.js";import{G as ye}from"./GoogleIcon.Dvw9apY0.js";import{U as G}from"./UnlinkIcon.BqVx4cPw.js";import{C as be}from"./Select.BJwzSgTp.js";import{s as Pe,i as ge,y as we}from"./youtubeChannel.CB9N3PkZ.js";/* empty css                        */import{u as ke}from"./i18n.CnDgzqyN.js";import"./recharts.CxMvZdXo.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"9285efe8a8dce1f690960d89b06301901087e606"},n._sentryModuleMetadata=n._sentryModuleMetadata||{},n._sentryModuleMetadata[new n.Error().stack]=function(h){for(var g=1;g<arguments.length;g++){var w=arguments[g];if(w!=null)for(var p in w)w.hasOwnProperty(p)&&(h[p]=w[p])}return h}({},n._sentryModuleMetadata[new n.Error().stack],{"_sentryBundlerPluginAppKey:tuf-website":!0});var i=new n.Error().stack;i&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[i]="73d2f2b3-d82a-48ef-a1b6-c3d43dd54eca",n._sentryDebugIdIdentifier="sentry-dbid-73d2f2b3-d82a-48ef-a1b6-c3d43dd54eca")}catch{}})();const xe=[{id:"discord",showProviderId:!0,linkClass:"link-button btn-fill-discord"},{id:"google",showProviderId:!1,linkClass:"link-button google-link-button"}],H=({provider:n,size:i,color:h="#fff"})=>{switch(n){case"discord":return e.jsx(he,{size:i,color:h});case"google":return e.jsx(ye,{size:i});default:return null}},Se=()=>{var $;const{t:n}=ke(["pages","common"]),{user:i,changePassword:h,linkProvider:g,unlinkProvider:w,fetchUser:p,registerPasskey:K}=fe(),{requireElevation:y}=me(),[l,L]=c.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[D,u]=c.useState(""),[S,f]=c.useState(""),[J,A]=c.useState(!1),z=(i==null?void 0:i.password)===null,[T,U]=c.useState([]),[Q,Z]=c.useState(!0),[F,v]=c.useState(null),W=typeof window<"u"&&typeof window.PublicKeyCredential<"u",[j,C]=c.useState(!1),[M,B]=c.useState(!1),N=s=>{const{name:t,value:a}=s.target;L(r=>({...r,[t]:a}))},O=async s=>{var t,a,r,d;if(s.preventDefault(),u(""),f(""),l.newPassword!==l.confirmPassword){u(n("editProfile.error.newPasswordsDoNotMatch"));return}try{await y("security",()=>h({currentPassword:l.currentPassword,newPassword:l.newPassword})),f(n("editProfile.success.passwordChanged")),L({currentPassword:"",newPassword:"",confirmPassword:""}),A(!1)}catch(o){if((o==null?void 0:o.code)==="ELEVATION_CANCELLED")return;const ue=((a=(t=o.response)==null?void 0:t.data)==null?void 0:a.error)||((d=(r=o.response)==null?void 0:r.data)==null?void 0:d.message)||o.message||n("editProfile.error.failedToChangePassword");u(ue)}},_=c.useCallback(async()=>{var s;Z(!0);try{const t=await b.get(P.auth.passkeys.list());U(Array.isArray((s=t.data)==null?void 0:s.passkeys)?t.data.passkeys:[])}catch(t){console.error("Failed to load passkeys:",t),U([])}finally{Z(!1)}},[]);c.useEffect(()=>{_()},[_]);const V=s=>{if(!s)return n("editProfile.passkeys.never");const t=s instanceof Date?s:new Date(s);return Number.isNaN(t.getTime())?n("editProfile.passkeys.never"):new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)},X=async()=>{var s,t;try{const a=await y("security",()=>K());if(a!=null&&a.cancelled)return;m.success(n("editProfile.passkeys.addSuccess")),await _()}catch(a){if((a==null?void 0:a.code)==="ELEVATION_CANCELLED")return;m.error(((t=(s=a==null?void 0:a.response)==null?void 0:s.data)==null?void 0:t.message)||(a==null?void 0:a.message)||n("editProfile.passkeys.addError"))}},ee=async s=>{var r,d;const t=window.prompt(n("editProfile.passkeys.renamePrompt"),s.name);if(t==null)return;const a=t.trim();if(!(!a||a===s.name)){v(s.id);try{await b.patch(P.auth.passkeys.byId(s.id),{name:a}),await _()}catch(o){m.error(((d=(r=o==null?void 0:o.response)==null?void 0:r.data)==null?void 0:d.message)||(o==null?void 0:o.message)||n("editProfile.passkeys.addError"))}finally{v(null)}}},se=async s=>{var t,a;if(window.confirm(n("editProfile.passkeys.deleteConfirm",{name:s.name}))){v(s.id);try{await y("security",()=>
1b.delete(P.auth.passkeys.byId(s.id))),m.success(n("editProfile.passkeys.deleteSuccess")),await _()}catch(r){if((r==null?void 0:r.code)==="ELEVATION_CANCELLED")return;m.error(((a=(t=r==null?void 0:r.response)==null?void 0:t.data)==null?void 0:a.message)||(r==null?void 0:r.message)||n("editProfile.passkeys.deleteError"))}finally{v(null)}}},ne=async s=>{var t,a;try{u(""),f(""),await g(s),f(n("editProfile.success.accountLinked",{provider:s}))}catch(r){u(((a=(t=r.response)==null?void 0:t.data)==null?void 0:a.error)||n("editProfile.error.failedToLinkAccount",{provider:s}))}},te=async s=>{var t,a,r,d;try{await y("security",()=>w(s)),f(n("editProfile.success.accountUnlinked",{provider:s}))}catch(o){if((o==null?void 0:o.code)==="ELEVATION_CANCELLED")return;u(((a=(t=o.response)==null?void 0:t.data)==null?void 0:a.error)||((d=(r=o.response)==null?void 0:r.data)==null?void 0:d.message)||o.message||n("editProfile.error.failedToUnlinkAccount",{provider:s}))}},k=Pe(i==null?void 0:i.youtubeChannels),x=k.find(s=>s.isPrimary)||k[0]||null,Y=k.map(s=>({value:s.channelId,label:s.handle?n("editProfile.linkedAccounts.youtubeHandle",{handle:s.handle.replace(/^@/,"")}):s.title||s.channelId})),q=async()=>{var s,t,a,r;try{u(""),f(""),await g("youtube"),f(n("editProfile.linkedAccounts.youtubeLinked"))}catch(d){u(((t=(s=d.response)==null?void 0:s.data)==null?void 0:t.error)||((r=(a=d.response)==null?void 0:a.data)==null?void 0:r.message)||d.message||n("editProfile.linkedAccounts.youtubeLinkFailed"))}},ae=async s=>{var t,a,r,d;try{u(""),f(""),await y("security",async()=>{await b.delete(P.auth.youtubeChannels.unlink(s)),await p()}),f(n("editProfile.linkedAccounts.youtubeUnlinked"))}catch(o){if((o==null?void 0:o.code)==="ELEVATION_CANCELLED")return;u(((a=(t=o.response)==null?void 0:t.data)==null?void 0:a.error)||((d=(r=o.response)==null?void 0:r.data)==null?void 0:d.message)||o.message||n("editProfile.linkedAccounts.youtubeUnlinkFailed"))}},ie=async s=>{var t,a,r,d;if(!(!s||s===(x==null?void 0:x.channelId)))try{u(""),f(""),await y("security",async()=>{await b.post(P.auth.youtubeChannels.setPrimary(s)),await p()}),f(n("editProfile.linkedAccounts.youtubePrimarySet"))}catch(o){if((o==null?void 0:o.code)==="ELEVATION_CANCELLED")return;u(((a=(t=o.response)==null?void 0:t.data)==null?void 0:a.error)||((d=(r=o.response)==null?void 0:r.data)==null?void 0:d.message)||o.message||n("editProfile.linkedAccounts.youtubePrimaryFailed"))}},I=(i==null?void 0:i.password)===null&&(($=i==null?void 0:i.providers)==null?void 0:$.length)===1,re=!!(i!=null&&i.deletionExecuteAt&&(i!=null&&i.deletionScheduledAt)),R=s=>{if(!s)return"";const t=s instanceof Date?s:new Date(s);return Number.isNaN(t.getTime())?"":t.toLocaleString()},oe=async()=>{var s,t,a,r;if(window.confirm(n("editProfile.dangerZone.confirmDelete"))){C(!0);try{await y("security",()=>b.post(`${P.auth.profile.root()}
1/me/delete`,{deletionIncludeCreator:!!(i!=null&&i.creatorId)&&!!M})),await p(!0),B(!1),m.success(n("editProfile.dangerZone.successScheduled"))}catch(d){if((d==null?void 0:d.code)==="ELEVATION_CANCELLED")return;m.error(((t=(s=d.response)==null?void 0:s.data)==null?void 0:t.error)||((r=(a=d.response)==null?void 0:a.data)==null?void 0:r.message)||n("editProfile.dangerZone.errorSchedule"))}finally{C(!1)}}},de=async()=>{var s,t;if(window.confirm(n("editProfile.dangerZone.confirmCancel"))){C(!0);try{await b.post(`${P.auth.profile.root()}/me/delete/cancel`),await p(!0),m.success(n("editProfile.dangerZone.successCanceled"))}catch(a){m.error(((t=(s=a.response)==null?void 0:s.data)==null?void 0:t.error)||n("editProfile.dangerZone.errorCancel"))}finally{C(!1)}}},le=c.useMemo(()=>!l.newPassword.trim()&&!l.confirmPassword.trim(),[l.newPassword,l.confirmPassword]),ce=c.useMemo(()=>!l.currentPassword.trim()&&!l.newPassword.trim()&&!l.confirmPassword.trim(),[l.currentPassword,l.newPassword,l.confirmPassword]);return e.jsxs("div",{className:"settings-sub-page settings-security-page page-content-600",children:[e.jsx("h2",{className:"settings-sub-page__title",children:n("settings.security.title")}),D&&e.jsx("div",{className:"error-message",children:D}),S&&e.jsx("div",{className:"success-message",children:S}),e.jsxs("div",{className:"settings-security-page__section",children:[e.jsx("h3",{className:"settings-security-page__section-title",children:n(z?"editProfile.password.addPassword":"editProfile.password.title")}),z?e.jsxs("form",{onSubmit:O,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"security-newPassword",children:n("editProfile.password.newPassword")}),e.jsx("input",{className:"input-field",type:"password",id:"security-newPassword",name:"newPassword",value:l.newPassword,onChange:N,required:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"security-confirmPassword",children:n("editProfile.password.confirmPassword")}),e.jsx("input",{className:"input-field",type:"password",id:"security-confirmPassword",name:"confirmPassword",value:l.confirmPassword,onChange:N,required:!0})]}),e.jsx("button",{type:"submit",className:"save-button btn-fill-primary btn-block",disabled:le,children:n("editProfile.password.createPassword")})]}):J?e.jsxs("form",{onSubmit:O,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"security-currentPassword",children:n("editProfile.password.currentPassword")}),e.jsx("input",{className:"input-field",type:"password",id:"security-currentPassword",name:"currentPassword",value:l.currentPassword,onChange:N,required:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"security-newPassword-change",children:n("editProfile.password.newPassword")}),e.jsx("input",{className:"input-field",type:"password",id:"security-newPassword-change",name:"newPassword",value:l.newPassword,onChange:N,required:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"security-confirmPassword-change",children:n("editProfile.password.confirmNewPassword")}),e.jsx("input",{className:"input-field",type:"password",id:"security-confirmPassword-change",name:"confirmPassword",value:l.confirmPassword,onChange:N,required:!0})]}),e.jsx("button",{type:"submit",className:"save-button btn-fill-primary btn-block",disabled:ce,children:n("editProfile.password.updatePassword")}),e.jsx("button",{type:"button",className:"change-password-button btn-fill-secondary btn-block",onClick:()=>A(!1),children:n("buttons.cancel",{ns:"common"})})]}):e.jsx("button",{type:"button",className:"change-password-button btn-fill-secondary btn-block",onClick:()=>A(!0),children:n("editProfile.password.changePassword")})]}),e.jsxs("div",{className:"settings-security-page__section",children:[e.jsx("h3",{className:"settings-security-page__section-title",children:n("editProfile.passkeys.title")}),e.jsx("p",{className:"passkeys-subtitle",children:n("editProfile.passkeys.subtitle")}),Q?e.jsx("p",{className:"passkeys-empty",children:n("loading.loading",{ns:"common",defaultValue:"Loading…"})}):T.length===0?e.jsx("p",{className:"passkeys-empty",children:n("editProfile.passkeys.empty")}):e.jsx("ul",{className:"passkeys-list",children:T.map(s=>e.jsxs("li",{className:"passkeys-row",children:[e.jsxs("div",{className:"passkeys-row-main",children:[e.jsxs("div",{className:"passkeys-row-title",children:[e.jsx("span",{className:"passkeys-name",children:s.name}),s.backedUp?e.jsx("span",{className:"passkeys-badge",children:n("editProfile.passkeys.synced")}):null]}),e.jsxs("div",{className:"passkeys-meta",children:[e.jsxs("span",{children:[n("editProfile.passkeys.added"),": ",V(s.createdAt)]}),e.jsxs("span",{children:[n("editProfile.passkeys.lastUsed"),": ",V(s.lastUsedAt)]})]})]}),e.jsxs("div",{className:"passkeys-row-actions",children:[e.jsx("button",{type:"button",className:"settings-sub-page__btn btn-fill-secondary",onClick:()=>ee(s),disabled:F===s.id,children:n("editProfile.passkeys.rename")}
1),e.jsx("button",{type:"button",className:"settings-sub-page__btn btn-fill-danger",onClick:()=>se(s),disabled:F===s.id,children:n("editProfile.passkeys.delete")})]})]},s.id))}),W?e.jsx("button",{type:"button",className:"change-password-button btn-fill-secondary btn-block",onClick:X,children:n("editProfile.passkeys.add")}):e.jsx("p",{className:"passkeys-empty",children:n("editProfile.passkeys.unsupported")})]}),e.jsxs("div",{className:"settings-security-page__section",children:[e.jsx("h3",{className:"settings-security-page__section-title",children:n("editProfile.linkedAccounts.title")}),e.jsxs("div",{className:"linked-accounts",children:[xe.map(s=>{var a;const t=(a=i==null?void 0:i.providers)==null?void 0:a.find(r=>r.name===s.id);return t?e.jsxs("div",{className:"provider-info",children:[e.jsxs("div",{className:"provider-details-column",children:[e.jsxs("div",{className:"provider-details",children:[e.jsx(H,{provider:s.id,size:32}),e.jsx("span",{children:n(`editProfile.linkedAccounts.${s.id}`)})]}),s.showProviderId&&t.providerId!=null&&t.providerId!==""&&e.jsx("span",{className:"provider-id-line",title:n("editProfile.linkedAccounts.providerIdHint"),children:n("editProfile.linkedAccounts.providerId",{id:String(t.providerId)})})]}),e.jsxs("div",{className:"unlink-container",children:[e.jsxs("button",{type:"button",className:`unlink-button btn-fill-danger ${I?"disabled":""}`,onClick:()=>te(s.id),disabled:I,"data-tooltip-id":"security-unlink-tooltip","data-tooltip-content":I?n("editProfile.linkedAccounts.cannotUnlinkLastProvider"):void 0,children:[n("editProfile.linkedAccounts.unlink"),e.jsx(G,{color:"#fff",size:"24px"})]}),e.jsx(pe,{id:"security-unlink-tooltip"})]})]},s.id):e.jsxs("button",{type:"button",className:s.linkClass,onClick:()=>ne(s.id),children:[e.jsx(H,{provider:s.id,size:16}),n(`editProfile.linkedAccounts.link${s.id==="discord"?"Discord":"Google"}`)]},s.id)}),ge(i)?e.jsxs("div",{className:"youtube-channels",children:[e.jsxs("div",{className:"youtube-channels__header",children:[e.jsx(E,{size:28}),e.jsxs("div",{className:"youtube-channels__titles",children:[e.jsx("span",{children:n("editProfile.linkedAccounts.youtube")}),e.jsx("p",{className:"youtube-channels__subtitle",children:n("editProfile.linkedAccounts.youtubeSubtitle")})]})]}),k.length>0?e.jsxs(e.Fragment,{children:[k.length>1?e.jsx(be,{label:n("editProfile.linkedAccounts.youtubePrimary"),options:Y,value:Y.find(s=>s.value===(x==null?void 0:x.channelId))||null,onChange:s=>{s!=null&&s.value&&ie(s.value)},width:"100%"}):null,e.jsx("ul",{className:"youtube-channels__list",children:k.map(s=>e.jsxs("li",{className:"youtube-channels__row",children:[e.jsxs("a",{className:"youtube-channels__link",href:s.url||we(s),target:"_blank",rel:"noopener noreferrer",children:[e.jsx("span",{className:"youtube-channels__name",children:s.handle?n("editProfile.linkedAccounts.youtubeHandle",{handle:s.handle.replace(/^@/,"")}):s.title||s.channelId}),e.jsx("span",{className:"youtube-channels__id",children:n("editProfile.linkedAccounts.youtubeChannelId",{id:s.channelId})})]}),e.jsxs("button",{type:"button",className:"unlink-button btn-fill-danger",onClick:()=>ae(s.channelId),children:[n("editProfile.linkedAccounts.youtubeUnlink"),e.jsx(G,{color:"#fff",size:"24px"})]})]},s.channelId))}),e.jsxs("button",{type:"button",className:"btn-fill-secondary btn-block link-button youtube-link-button",onClick:()=>void q(),children:[e.jsx(E,{size:16}),n("editProfile.linkedAccounts.linkAnotherYoutube")]})]}):e.jsxs("button",{type:"button",className:"btn-fill-secondary btn-block link-button youtube-link-button",onClick:()=>void q(),children:[e.jsx(E,{size:16}),n("editProfile.linkedAccounts.linkYoutube")]})]}):null]})]}),e.jsx("div",{className:"settings-security-page__section",children:e.jsxs("div",{className:"danger-zone",children:[e.jsx("h3",{children:n("editProfile.dangerZone.title")}),e.jsx("p",{className:"danger-zone__description",children:n("editProfile.dangerZone.description")}),re?e.jsxs("div",{className:"danger-zone__pending",children:[e.jsx("p",{className:"danger-zone__pending-title",children:n("editProfile.dangerZone.pendingTitle")}),e.jsxs("ul",{className:"danger-zone__dates",children:[e.jsx("li",{children:n("editProfile.dangerZone.sc
1heduledAt",{date:R(i.deletionScheduledAt)})}),e.jsx("li",{children:n("editProfile.dangerZone.executesAt",{date:R(i.deletionExecuteAt)})}),i.deletionIncludeCreator?e.jsx("li",{className:"danger-zone__dates-note",children:n("editProfile.dangerZone.pendingIncludesCreator")}):null]}),e.jsx("div",{className:"danger-zone__actions",children:e.jsx("button",{type:"button",className:"button danger-zone__button danger-zone__button--secondary btn-fill-neutral-heavy",onClick:de,disabled:j,children:n(j?"editProfile.dangerZone.canceling":"editProfile.dangerZone.cancelButton")})})]}):e.jsxs("div",{className:"danger-zone__schedule-block",children:[i!=null&&i.creatorId?e.jsxs("label",{className:"danger-zone__include-creator",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:s=>B(s.target.checked),disabled:j}),e.jsx("span",{children:n("editProfile.dangerZone.includeCreatorCheckbox")})]}):null,e.jsx("div",{className:"danger-zone__actions",children:e.jsx("button",{type:"button",className:"button danger-zone__button danger-zone__button--destructive btn-fill-danger",onClick:oe,disabled:j,children:n(j?"editProfile.dangerZone.scheduling":"editProfile.dangerZone.deleteButton")})})]})]})})]})};export{Se as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.