pixelfed/public/js/remote_auth.js

1 line
349 KiB
JavaScript
Raw Normal View History

2023-07-17 04:59:52 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[8385],{33527:(t,r,o)=>{"use strict";o.r(r),o.d(r,{default:()=>n});var e=o(36357),a=o(35953);const n={components:{InstagramLoader:e.InstagramLoader,RegisterForm:a.default},data:function(){return{loaded:!1,error:!1,prefill:!1,existing:void 0,maxUsesReached:void 0,tab:"loading",canReload:!1}},mounted:function(){this.validateSession(),window.onbeforeunload=function(){if(!this.canReload)return alert("You are trying to leave."),!1}},methods:{validateSession:function(){var t=this;axios.post("/auth/raw/mastodon/s/check").then((function(r){if(r||r.hasOwnProperty("action"))switch(r.data.action){case"onboard":return void t.getPrefillData();case"redirect_existing_user":return t.existing=!0,t.canReload=!0,window.onbeforeunload=void 0,void t.redirectExistingUser();case"max_uses_reached":return t.maxUsesReached=!0,t.canReload=!0,void(window.onbeforeunload=void 0);default:return void(t.error=!0)}else swal("Oops!","An unexpected error occured, please try again later","error")})).catch((function(r){t.canReload=!0,window.onbeforeunload=void 0,t.error=!0}))},setCanReload:function(){this.canReload=!0,window.onbeforeunload=void 0},redirectExistingUser:function(){var t=this;this.canReload=!0,setTimeout((function(){t.handleLogin()}),1500)},handleLogin:function(){var t=this;axios.post("/auth/raw/mastodon/s/login").then((function(t){setTimeout((function(){window.location.reload()}),1500)})).catch((function(r){t.canReload=!1,t.error=!0}))},getPrefillData:function(){var t=this;axios.post("/auth/raw/mastodon/s/prefill").then((function(r){t.prefill=r.data})).catch((function(r){t.error=!0})).finally((function(){setTimeout((function(){t.loaded=!0}),1e3)}))}}}},62779:(t,r,o)=>{"use strict";o.r(r),o.d(r,{default:()=>e});const e={data:function(){return{loaded:!1,domains:[]}},mounted:function(){this.fetchDomains()},methods:{fetchDomains:function(){var t=this;axios.post("/auth/raw/mastodon/domains").then((function(r){t.domains=r.data})).finally((function(){setTimeout((function(){t.loaded=!0}),500)}))},handleRedirect:function(t){axios.post("/auth/raw/mastodon/redirect",{domain:t}).then((function(r){r&&r.data.hasOwnProperty("ready")&&(r.data.hasOwnProperty("action")&&"incompatible_domain"===r.data.action?swal("Oops!","This server is not compatible, please choose another or try again later!","error"):r.data.ready&&(window.location.href="/auth/raw/mastodon/preflight?d="+t+"&dsh="+r.data.dsh))}))},handleOther:function(){var t=this;swal({text:"Enter your mastodon domain (without https://)",content:"input",button:{text:"Next",closeModal:!1}}).then((function(r){if(!r)throw null;if(!r.startsWith("https://"))return t.handleRedirect(r)}))}}}},71456:(t,r,o)=>{"use strict";o.r(r),o.d(r,{default:()=>n});var e=o(93410),a=o(36357);const n={props:{initialData:{type:Object}},components:{InstagramLoader:a.InstagramLoader},data:function(){return{step:1,validUsername:!1,usernameError:void 0,username:this.initialData.username,email:void 0,emailError:void 0,validEmail:!1,password:void 0,passwordConfirm:void 0,passwordValid:!1,following:[],followingFetched:!1,selectedFollowing:[],form:{importAvatar:!0,bio:this.stripTagsPreserveNewlines(this.initialData.note),display_name:this.initialData.display_name},isSubmitting:!1,submitProgress:0,submitMessage:"Please wait...",isImportingFollowing:!1,accountToId:[],followingIds:[],accessToken:void 0}},mounted:function(){this.checkUsernameAvailability()},watch:{username:(0,e.debounce)((function(t){this.checkUsernameAvailability()}),500),email:(0,e.debounce)((function(t){this.checkEmailAvailability()}),500),passwordConfirm:function(t){this.checkPasswordConfirm(t)},selectedFollowing:function(t){this.lookupSelected(t)}},methods:{checkPasswordConfirm:function(t){this.password&&t&&(this.passwordValid=t.trim()===this.password.trim())},handleBack:function(){event.currentTarget.blur(),this.step--},handleProceed:function(){event.currentTarget.blur(),this.step++,this.followingFetched||this.fetchFollowing()},checkUsernameAvailability:function(){var t=this;axios.post("/auth/raw/mastodon/s/us