blob: ec8bc5a0625b20c5482e8f55a23d36fc5228d5c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import FormError from 'components/form_error.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import PropTypes from 'prop-types';
import React from 'react';
import icon50 from 'images/icon50x50.png';
import {getOAuthAppInfo, allowOAuth2} from 'actions/admin_actions.jsx';
export default class Authorize extends React.Component {
static get propTypes() {
return {
location: PropTypes.object.isRequired,
params: PropTypes.object.isRequired
};
}
constructor(props) {
super(props);
this.handleAllow = this.handleAllow.bind(this);
this.handleDeny = this.handleDeny.bind(this);
this.state = {};
}
componentWillMount() {
getOAuthAppInfo(
this.props.location.query.client_id,
(app) => {
this.setState({app});
}
);
}
componentDidMount() {
// if we get to this point remove the antiClickjack blocker
const blocker = document.getElementById('antiClickjack');
if (blocker) {
blocker.parentNode.removeChild(blocker);
}
}
handleAllow() {
const params = this.props.location.query;
allowOAuth2(params,
(data) => {
if (data.redirect) {
window.location.href = data.redirect;
}
},
(err) => {
this.setState({error: err.message});
}
);
}
handleDeny() {
window.location.replace(this.props.location.query.redirect_uri + '?error=access_denied');
}
render() {
const app = this.state.app;
if (!app) {
return null;
}
let icon;
if (app.icon_url) {
icon = app.icon_url;
} else {
icon = icon50;
}
let error;
if (this.state.error) {
error = (
<div className='prompt__error form-group'>
<FormError error={this.state.error}/>
</div>
);
}
return (
<div className='container-fluid'>
<div className='prompt'>
<div className='prompt__heading'>
<div className='prompt__app-icon'>
<img
src={icon}
width='50'
height='50'
alt=''
/>
</div>
<div className='text'>
<FormattedHTMLMessage
id='authorize.title'
defaultMessage='<strong>{appName}</strong> would like to connect to your <strong>Mattermost</strong> user account'
values={{
appName: app.name
}}
/>
</div>
</div>
<p>
<FormattedHTMLMessage
id='authorize.app'
defaultMessage='The app <strong>{appName}</strong> would like the ability to access and modify your basic information.'
values={{
appName: app.name
}}
/>
</p>
<h2 className='prompt__allow'>
<FormattedHTMLMessage
id='authorize.access'
defaultMessage='Allow <strong>{appName}</strong> access?'
values={{
appName: app.name
}}
/>
</h2>
<div className='prompt__buttons'>
<button
type='submit'
className='btn btn-link authorize-btn'
onClick={this.handleDeny}
>
<FormattedMessage
id='authorize.deny'
defaultMessage='Deny'
/>
</button>
<button
type='submit'
className='btn btn-primary authorize-btn'
onClick={this.handleAllow}
>
<FormattedMessage
id='authorize.allow'
defaultMessage='Allow'
/>
</button>
</div>
{error}
</div>
</div>
);
}
}
|