From 5e7d063449ddf98a9c7c6adab3fc881e106b9100 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Mon, 29 Feb 2016 20:16:33 +0200 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=BD=D0=B4=D0=B5=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D0=B3=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D1=81?= =?UTF-8?q?=D0=BA=D0=BE=D1=83=D0=BF=D0=BE=D0=B2=20=D0=BD=D0=B0=20oauth/per?= =?UTF-8?q?missions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/auth/Permissions.jsx | 22 ++++++++++++--------- src/components/auth/Permissions.messages.js | 10 ++++++++++ src/components/auth/actions.js | 13 ++++++++++++ src/components/auth/reducer.js | 18 +++++++++++++++-- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/components/auth/Permissions.jsx b/src/components/auth/Permissions.jsx index 7cc8f11..c057bfa 100644 --- a/src/components/auth/Permissions.jsx +++ b/src/components/auth/Permissions.jsx @@ -18,14 +18,13 @@ class Body extends BaseAuthBody { oAuthComplete: PropTypes.func.isRequired, auth: PropTypes.shape({ error: PropTypes.string, - login: PropTypes.shape({ - login: PropTypes.stirng - }) + scopes: PropTypes.array.isRequired }) }; render() { const {user} = this.props; + const scopes = this.props.auth.scopes; return (
@@ -53,10 +52,9 @@ class Body extends BaseAuthBody {
@@ -83,8 +81,14 @@ export default function Permissions() { ), - Links: () => ( - + Links: (props) => ( + { + event.preventDefault(); + + props.onAuthComplete({ + accept: false + }); + }}> ) diff --git a/src/components/auth/Permissions.messages.js b/src/components/auth/Permissions.messages.js index b1d4c56..bde9236 100644 --- a/src/components/auth/Permissions.messages.js +++ b/src/components/auth/Permissions.messages.js @@ -29,5 +29,15 @@ export default defineMessages({ approve: { id: 'approve', defaultMessage: 'Approve' + }, + + scope_minecraft_server_session: { + id: 'scope_minecraft_server_session', + defaultMessage: 'Authorization data for minecraft server' + }, + + scope_offline_access: { + id: 'scope_offline_access', + defaultMessage: 'Access to your profile data, when you offline' } }); diff --git a/src/components/auth/actions.js b/src/components/auth/actions.js index f86f253..1e9a031 100644 --- a/src/components/auth/actions.js +++ b/src/components/auth/actions.js @@ -155,6 +155,7 @@ export function oAuthValidate(oauth) { .then((resp) => { dispatch(setClient(resp.client)); dispatch(setOAuthRequest(resp.oAuth)); + dispatch(setScopes(resp.session.scopes)); }) .catch((resp = {}) => { // TODO handleOauthParamsValidation(resp); @@ -246,3 +247,15 @@ export function setOAuthRequest(oauth) { } }; } + +export const SET_SCOPES = 'set_scopes'; +export function setScopes(scopes) { + if (!(scopes instanceof Array)) { + throw new Error('Scopes must be array'); + } + + return { + type: SET_SCOPES, + payload: scopes + }; +} diff --git a/src/components/auth/reducer.js b/src/components/auth/reducer.js index 55a6a42..402b3a3 100644 --- a/src/components/auth/reducer.js +++ b/src/components/auth/reducer.js @@ -1,11 +1,12 @@ import { combineReducers } from 'redux'; -import { ERROR, SET_CLIENT, SET_OAUTH } from './actions'; +import { ERROR, SET_CLIENT, SET_OAUTH, SET_SCOPES } from './actions'; export default combineReducers({ error, client, - oauth + oauth, + scopes }); function error( @@ -59,3 +60,16 @@ function oauth( return state; } } + +function scopes( + state = [], + {type, payload = []} +) { + switch (type) { + case SET_SCOPES: + return payload; + + default: + return state; + } +}