"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[9420],{9420(e,t,a){a.r(t),a.d(t,{default:()=>h});var r=a(37270),s=a(32446),l=a(88563),o=(a(5673),a(30164),a(21279),a(36418)),n=a(14778),c=a(14891),i=a(85990),m=a(5185),p=a(83007);class d extends o.PureComponent{constructor(e){super(e),this.state={}}componentDidMount(){const e=document.getElementById("antiClickjack");e&&e.parentNode&&e.parentNode.removeChild(e);const t=new URLSearchParams(this.props.location.search).get("client_id");t&&!/^[a-z0-9]+$/.test(t)||this.props.actions.getOAuthAppInfo(t).then(({data:e})=>{e&&this.setState({app:e})})}handleAllow=()=>{const e=new URLSearchParams(this.props.location.search),t={responseType:e.get("response_type"),clientId:e.get("client_id"),redirectUri:e.get("redirect_uri"),state:e.get("state"),scope:e.get("scope"),resource:e.get("resource"),codeChallenge:e.get("code_challenge"),codeChallengeMethod:e.get("code_challenge_method")};this.props.actions.allowOAuth2(t).then(({data:e,error:t})=>{e&&e.redirect?window.location.href=e.redirect:t&&this.setState({error:t.message})})};handleDeny=()=>{const e=new URLSearchParams(this.props.location.search).get("redirect_uri");e&&(e.startsWith("https://")||e.startsWith("http://"))?window.location.href=e+"?error=access_denied":(0,p.J)().replace("/error")};render(){const e=this.state.app;if(!e)return null;let t,a;return t=e.icon_url?e.icon_url:m,this.state.error&&(a=o.createElement("div",{className:"prompt__error form-group"},o.createElement(i.Ay,{error:this.state.error}))),o.createElement("div",{className:"container-fluid"},o.createElement("div",{className:"prompt"},o.createElement("div",{className:"prompt__heading"},o.createElement("div",{className:"prompt__app-icon"},o.createElement("img",{alt:"prompt icon",src:t,width:"50",height:"50"})),o.createElement("div",{className:"text"},o.createElement(n.FormattedMessage,{id:"authorize.connectTitle",defaultMessage:"Authorize <b>{appName}</b> to Connect to Your <b>Mattermost</b> User Account",values:{appName:e.name,b:e=>o.createElement("b",null,e)}}))),o.createElement("p",null,o.createElement(n.FormattedMessage,{id:"authorize.modificationAccess",defaultMessage:"The app <b>{appName}</b> would like the ability to access and modify your basic information.",values:{appName:e.name,b:e=>o.createElement("b",null,e)}})),o.createElement("h2",{className:"prompt__allow"},o.createElement(n.FormattedMessage,{id:"authorize.allowAccess",defaultMessage:"Allow <b>{appName}</b> access?",values:{appName:e.name,b:e=>o.createElement("b",null,e)}})),o.createElement("div",{className:"prompt__buttons"},o.createElement(c.Button,{type:"submit",emphasis:"tertiary",className:"authorize-btn",onClick:this.handleDeny},o.createElement(n.FormattedMessage,{id:"authorize.deny",defaultMessage:"Deny"})),o.createElement(c.Button,{type:"submit",emphasis:"primary",className:"authorize-btn",onClick:this.handleAllow},o.createElement(n.FormattedMessage,{id:"authorize.allow",defaultMessage:"Allow"}))),a))}}const h=(0,r.connect)(null,function(e){return{actions:(0,s.zH)({getOAuthAppInfo:l.LB,allowOAuth2:l.hg},e)}})(d)},85990(e,t,a){a.d(t,{Ay:()=>n,Nq:()=>s});var r=a(36418);const s="backstage",l=[],o=({error:e=null,errors:t=l,iconClassName:a,margin:o,textClassName:n,type:c})=>{if(!e&&0===t.length)return null;let i=e;if(!i)for(const e of t)e&&(i=e);return i?"modal"===c?r.createElement("div",{className:"form-group"},r.createElement("label",{className:"col-sm-12 has-error"},i)):c===s?r.createElement("div",{className:"pull-left has-error"},r.createElement("label",{className:"control-label"},i)):o?r.createElement("div",{className:"form-group has-error"},r.createElement("label",{className:"control-label"},i)):r.createElement("div",{className:`col-sm-12 ${n||"has-error"}`},r.createElement("label",{className:"control-label"},r.createElement("i",{className:`fa ${a||"fa-exclamation-circle"}`})," ",i)):null},n=r.memo(o)}}]);
//# sourceMappingURL=9420.165affd3294159673c56.js.map