2016-05-14 16:56:17 +05:30
|
|
|
|
import React from 'react';
|
2020-06-04 22:11:27 +05:30
|
|
|
|
import { defineMessages, FormattedMessage as Message } from 'react-intl';
|
2019-12-08 00:32:00 +05:30
|
|
|
|
import icons from 'app/components/ui/icons.scss';
|
|
|
|
|
import { PanelBodyHeader } from 'app/components/ui/Panel';
|
|
|
|
|
import BaseAuthBody from 'app/components/auth/BaseAuthBody';
|
2016-05-14 16:56:17 +05:30
|
|
|
|
|
|
|
|
|
import styles from './permissions.scss';
|
2020-06-04 22:11:27 +05:30
|
|
|
|
|
|
|
|
|
const scopesMessages = defineMessages({
|
|
|
|
|
scope_minecraft_server_session: 'Authorization data for minecraft server',
|
|
|
|
|
scope_offline_access: 'Access to your profile data, when you offline',
|
|
|
|
|
scope_account_info: 'Access to your profile data (except E‑mail)',
|
|
|
|
|
scope_account_email: 'Access to your E‑mail address',
|
|
|
|
|
});
|
2016-05-14 16:56:17 +05:30
|
|
|
|
|
|
|
|
|
export default class PermissionsBody extends BaseAuthBody {
|
2020-05-24 04:38:24 +05:30
|
|
|
|
static displayName = 'PermissionsBody';
|
|
|
|
|
static panelId = 'permissions';
|
2019-11-27 14:33:32 +05:30
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
|
render() {
|
|
|
|
|
const { user } = this.context;
|
|
|
|
|
const { scopes } = this.context.auth;
|
2019-11-27 14:33:32 +05:30
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{this.renderErrors()}
|
2019-11-27 14:33:32 +05:30
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
|
<PanelBodyHeader>
|
|
|
|
|
<div className={styles.authInfo}>
|
|
|
|
|
<div className={styles.authInfoAvatar}>
|
|
|
|
|
{user.avatar ? <img src={user.avatar} /> : <span className={icons.user} />}
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles.authInfoTitle}>
|
2020-06-04 22:11:27 +05:30
|
|
|
|
<Message key="youAuthorizedAs" defaultMessage="You authorized as:" />
|
2020-05-24 04:38:24 +05:30
|
|
|
|
</div>
|
|
|
|
|
<div className={styles.authInfoEmail}>{user.username}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</PanelBodyHeader>
|
|
|
|
|
<div className={styles.permissionsContainer}>
|
|
|
|
|
<div className={styles.permissionsTitle}>
|
2020-06-04 22:11:27 +05:30
|
|
|
|
<Message key="theAppNeedsAccess1" defaultMessage="This application needs access" />
|
2020-05-24 04:38:24 +05:30
|
|
|
|
<br />
|
2020-06-04 22:11:27 +05:30
|
|
|
|
<Message key="theAppNeedsAccess2" defaultMessage="to your data" />
|
2020-05-24 04:38:24 +05:30
|
|
|
|
</div>
|
|
|
|
|
<ul className={styles.permissionsList}>
|
|
|
|
|
{scopes.map((scope) => {
|
|
|
|
|
const key = `scope_${scope}`;
|
2020-06-04 22:11:27 +05:30
|
|
|
|
// @ts-ignore
|
|
|
|
|
const message = scopesMessages[key];
|
2019-11-27 14:33:32 +05:30
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
|
return (
|
|
|
|
|
<li key={key}>
|
|
|
|
|
{message ? (
|
|
|
|
|
<Message {...message} />
|
|
|
|
|
) : (
|
|
|
|
|
scope.replace(/^\w|_/g, (match) => match.replace('_', ' ').toUpperCase())
|
|
|
|
|
)}
|
|
|
|
|
</li>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-05-14 16:56:17 +05:30
|
|
|
|
}
|