-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aae8360
commit 34177e4
Showing
6 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Component from '@ember/component'; | ||
import { get, set } from '@ember/object'; | ||
|
||
export default Component.extend({ | ||
isShown: true || window.explainRedirect, | ||
|
||
actions: { | ||
dismiss() { | ||
set(this, 'isShown', false); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const existingSession = window.localStorage['ember_simple_auth:session']; | ||
|
||
// Carefully parse the session | ||
const isLoggedIn = (() => { | ||
if (!existingSession) return false; | ||
|
||
try { | ||
return JSON.parse(existingSession)['authenticated']['access_token']; | ||
} catch (e) { | ||
return false; | ||
} | ||
})(); | ||
|
||
export function initialize() { | ||
if (window.location.origin.endsWith('.io')) { | ||
// Redirect to the new domain | ||
const url = new URL(window.location); | ||
url.host = url.host.replace('kitsu.io', 'kitsu.app'); | ||
|
||
url.hash = `kitsu-io-session=${btoa(existingSession)}`; | ||
|
||
window.location.replace(url.toString()); | ||
} else if (window.location.hash.match(/#kitsu-io-session=.*/)) { | ||
if (!isLoggedIn) { | ||
try { | ||
// Import the session from the hash | ||
const importedSession = JSON.parse(atob(/#kitsu-io-session=(.*)/.exec(window.location.hash)[1])); | ||
|
||
window.localStorage['ember_simple_auth:session'] = JSON.stringify(importedSession); | ||
} catch (e) { | ||
console.error('Failed to import session'); | ||
} | ||
} | ||
window.explainRedirect = true; | ||
const url = new URL(window.location); | ||
url.hash = ''; | ||
history.replaceState(null, '', url.toString()); | ||
} | ||
} | ||
|
||
export default { | ||
name: 'redirectFromKitsuIO', | ||
initialize | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{#if isShown}} | ||
<aside id="explain-redirect"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="inner"> | ||
<h5>We've Moved!</h5> | ||
Don't be alarmed by the URL, we've moved from Kitsu.io to Kitsu.app | ||
<span class="dismiss" {{action "dismiss"}}> | ||
{{svg-jar "close"}} | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</aside> | ||
{{/if}} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.