diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-02-22 01:05:23 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-02-22 01:05:23 +0900 |
| commit | 2a1fab34df0ae5a6e8bdaf5cd731ae50545328b6 (patch) | |
| tree | d933ca7fc272d107a234f6182b6acff6a6d11383 /src/web/app/auth | |
| parent | wip (diff) | |
| download | misskey-2a1fab34df0ae5a6e8bdaf5cd731ae50545328b6.tar.gz misskey-2a1fab34df0ae5a6e8bdaf5cd731ae50545328b6.tar.bz2 misskey-2a1fab34df0ae5a6e8bdaf5cd731ae50545328b6.zip | |
wip
Diffstat (limited to 'src/web/app/auth')
| -rw-r--r-- | src/web/app/auth/tags/form.tag | 12 | ||||
| -rw-r--r-- | src/web/app/auth/tags/index.tag | 62 |
2 files changed, 44 insertions, 30 deletions
diff --git a/src/web/app/auth/tags/form.tag b/src/web/app/auth/tags/form.tag index 619c71065e..4a236f7594 100644 --- a/src/web/app/auth/tags/form.tag +++ b/src/web/app/auth/tags/form.tag @@ -108,19 +108,23 @@ <script> this.mixin('api'); - this.session = this.opts.session - this.app = @session.app + this.session = this.opts.session; + this.app = this.session.app; this.cancel = () => { this.api('auth/deny', { - token: @session.token + token: this.session.token }).then(() => { this.trigger('denied'); + }); + }; this.accept = () => { this.api('auth/accept', { - token: @session.token + token: this.session.token }).then(() => { this.trigger('accepted'); + }); + }; </script> </mk-form> diff --git a/src/web/app/auth/tags/index.tag b/src/web/app/auth/tags/index.tag index e52aeed4d2..f80e9dd1bc 100644 --- a/src/web/app/auth/tags/index.tag +++ b/src/web/app/auth/tags/index.tag @@ -91,47 +91,57 @@ this.mixin('i'); this.mixin('api'); - this.state = null - this.fetching = true + this.state = null; + this.fetching = true; - this.token = window.location.href.split '/' .pop! + this.token = window.location.href.split('/').pop(); this.on('mount', () => { - if not this.SIGNIN then return + if (!this.SIGNIN) return; // Fetch session this.api('auth/session/show', { - token: @token - }).then((session) => { - this.session = session - this.fetching = false + token: this.token + }).then(session => { + this.session = session; + this.fetching = false; // 既に連携していた場合 - if @session.app.is_authorized + if (this.session.app.is_authorized) { this.api('auth/accept', { - token: @session.token + token: this.session.token }).then(() => { - @accepted! - else - this.state = 'waiting' - this.update(); + this.accepted(); + }); + } else { + this.update({ + state: 'waiting' + }); this.refs.form.on('denied', () => { - this.state = 'denied' - this.update(); + this.update({ + state: 'denied' + }); + }); - this.refs.form.on 'accepted' @accepted - - .catch (error) => - this.fetching = false - this.state = 'fetch-session-error' - this.update(); + this.refs.form.on('accepted', this.accepted); + } + }).catch(error => { + this.update({ + fetching: false, + state: 'fetch-session-error' + }); + }); + }); this.accepted = () => { - this.state = 'accepted' - this.update(); + this.update({ + state: 'accepted' + }); - if @session.app.callback_url - location.href = @session.app.callback_url + '?token=' + @session.token + if (this.session.app.callback_url) { + location.href = this.session.app.callback_url + '?token=' + this.session.token; + } + }; </script> </mk-index> |