"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[9744],{89744:(e,t,a)=>{a.r(t),a.d(t,{default:()=>b});var r=a(70314),n=a(36891),s=a(59713),i=a(86332),o=a.n(i),l=(a(14078),a(68581),a(52077),a(83526),a(90938),a(911),a(92189),a(84390)),c=a.n(l),p=a(72060),u=a(62355),m=a(38210),d=a(8243),h=a(2664);function f(e,t,a){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var r=a.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class g extends c().PureComponent{constructor(e){super(e),f(this,"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("store")};this.props.actions.allowOAuth2(t).then((e=>{let{data:t,error:a}=e;t&&t.redirect?window.location.href=t.redirect:a&&this.setState({error:a.message})}))})),f(this,"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,d.s)().replace("/error")})),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((e=>{let{data:t}=e;t&&this.setState({app:t})}))}render(){const e=this.state.app;if(!e)return null;let t,a;return t=e.icon_url?e.icon_url:u,this.state.error&&(a=c().createElement("div",{className:"prompt__error form-group"},c().createElement(m.Z,{error:this.state.error}))),c().createElement("div",{className:"container-fluid"},c().createElement("div",{className:"prompt"},c().createElement("div",{className:"prompt__heading"},c().createElement("div",{className:"prompt__app-icon"},c().createElement("img",{alt:"prompt icon",src:t,width:"50",height:"50"})),c().createElement("div",{className:"text"},c().createElement(h.Z,{id:"authorize.title",defaultMessage:"Authorize **{appName}** to Connect to Your **Mattermost** User Account",values:{appName:e.name}}))),c().createElement("p",null,c().createElement(h.Z,{id:"authorize.app",defaultMessage:"The app **{appName}** would like the ability to access and modify your basic information.",values:{appName:e.name}})),c().createElement("h2",{className:"prompt__allow"},c().createElement(h.Z,{id:"authorize.access",defaultMessage:"Allow **{appName}** access?",values:{appName:e.name}})),c().createElement("div",{className:"prompt__buttons"},c().createElement("button",{type:"submit",className:"btn btn-link authorize-btn",onClick:this.handleDeny},c().createElement(p.FormattedMessage,{id:"authorize.deny",defaultMessage:"Deny"})),c().createElement("button",{type:"submit",className:"btn btn-primary authorize-btn",onClick:this.handleAllow},c().createElement(p.FormattedMessage,{id:"authorize.allow",defaultMessage:"Allow"}))),a))}}f(g,"propTypes",{location:o().shape({search:o().string.isRequired}).isRequired,actions:o().shape({getOAuthAppInfo:o().func.isRequired,allowOAuth2:o().func.isRequired}).isRequired});const b=(0,r.connect)(null,(function(e){return{actions:(0,n.bindActionCreators)({getOAuthAppInfo:s.jI,allowOAuth2:s.yT},e)}}))(g)}}]);
//# sourceMappingURL=9744.92bf2482fecd296070af.js.map