new auth
This commit is contained in:
parent
088ec70928
commit
265129fd84
17
.idea/workspace.xml
generated
17
.idea/workspace.xml
generated
@ -5,22 +5,13 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="efee9cb0-966d-4623-845a-f3b0398ae3ab" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/app/assets/js/scripts/skirda/auth/telegram.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/app/loginSkirdaTelegram.ejs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/SkirdaElectronLauncher.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/SkirdaElectronLauncher.iml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/codeStyles/Project.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/codeStyles/Project.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" beforeDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/app/assets/js/scripts/loginSkirda.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/app.ejs" beforeDir="false" afterPath="$PROJECT_DIR$/app/app.ejs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/js/authmanager.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/authmanager.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/js/configmanager.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/configmanager.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/js/distromanager.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/distromanager.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/landing.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/landing.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/loginOptions.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/loginOptions.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/loginSkirdaDiscord.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/loginSkirdaDiscord.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/settings.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/settings.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/js/scripts/uibinder.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/js/scripts/uibinder.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/loginOptions.ejs" beforeDir="false" afterPath="$PROJECT_DIR$/app/loginOptions.ejs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/loginSkirdaTelegram.ejs" beforeDir="false" afterPath="$PROJECT_DIR$/app/loginSkirda.ejs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -57,7 +48,7 @@
|
||||
"git-widget-placeholder": "offline-mode",
|
||||
"go.import.settings.migrated": "true",
|
||||
"go.sdk.automatically.set": "true",
|
||||
"last_opened_file_path": "/home/dart/repo/skirda/SkirdaElectronLauncher",
|
||||
"last_opened_file_path": "/home/dart/repo/skirda/SkirdaElectronLauncher/app",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
|
@ -34,6 +34,7 @@
|
||||
<%- include('waiting') %>
|
||||
<%- include('loginOptions') %>
|
||||
<%- include('loginOffline') %>
|
||||
<%- include('loginSkirda') %>
|
||||
<%- include('loginSkirdaDiscord') %>
|
||||
<%- include('loginSkirdaTelegram') %>
|
||||
<%- include('settings') %>
|
||||
|
@ -2,6 +2,7 @@ const loginOptionsCancelContainer = document.getElementById('loginOptionCancelCo
|
||||
const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft')
|
||||
const loginOptionMojang = document.getElementById('loginOptionMojang')
|
||||
const loginOptionOffline = document.getElementById('loginOptionOffline')
|
||||
const loginOptionSkirdaAuth = document.getElementById('loginOptionSkirdaAuth')
|
||||
const loginOptionSkirdaDiskord = document.getElementById('loginOptionSkirdaDiscord')
|
||||
const loginOptionSkirdaTelegram = document.getElementById('loginOptionSkirdaTelegram')
|
||||
const loginOptionsCancelButton = document.getElementById('loginOptionCancelButton')
|
||||
@ -66,6 +67,26 @@ loginOptionSkirdaTelegram.onclick = (e) => {
|
||||
})
|
||||
}
|
||||
|
||||
loginOptionSkirdaAuth.onclick = (e) => {
|
||||
switchView(getCurrentView(), VIEWS.loginSkirdaAuth, 500, 500, () => {
|
||||
loginViewOnSuccess = loginOptionsViewOnLoginSuccess
|
||||
loginViewOnCancel = loginOptionsViewOnLoginCancel
|
||||
|
||||
SkirdaAuth.Init().then((result) => {
|
||||
console.log(result)
|
||||
|
||||
AuthManager.addSkirdaAccount(result.ygg_auth_resp.profile.id, result.skirda_auth_resp.token, result.skirda_auth_resp.name, result.skirda_auth_resp.name, result.skirda_auth_resp.token).then((value) => {
|
||||
console.log(value)
|
||||
updateSelectedAccount(value)
|
||||
}).then((value) => {
|
||||
switchView(getCurrentView(), VIEWS.landing, 500, 500, async () => {
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
loginOptionsCancelButton.onclick = (e) => {
|
||||
switchView(getCurrentView(), loginOptionsViewOnCancel, 500, 500, () => {
|
||||
// Clear login values (Mojang login)
|
||||
|
106
app/assets/js/scripts/loginSkirda.js
Normal file
106
app/assets/js/scripts/loginSkirda.js
Normal file
@ -0,0 +1,106 @@
|
||||
const sk_tg_auth_api_url = 'https://skirda.brzezinski.ru/auth'
|
||||
|
||||
/**@typedef {Object} SkirdaAuthInitResponse
|
||||
* @property {string} redirect_url
|
||||
* @property {string} subscribe_url
|
||||
* */
|
||||
|
||||
|
||||
|
||||
/**@typedef {Object} SkirdaAuthResponse
|
||||
* @property {string} id
|
||||
* @property {string} name
|
||||
*/
|
||||
|
||||
/**@typedef {Object} YggdrasilProfile
|
||||
* @property {string} id
|
||||
* @property {string} name
|
||||
*/
|
||||
|
||||
/**@typedef {Object} SkirdaYggdrasilAuthResponse
|
||||
* @property {YggdrasilProfile} profile
|
||||
*/
|
||||
|
||||
/** @typedef {Object} SkirdaAuthResultResponse
|
||||
* @property {SkirdaAuthResponse} skirda_auth_resp
|
||||
* @property {SkirdaYggdrasilAuthResponse} ygg_auth_resp
|
||||
**/
|
||||
|
||||
class SkirdaAuth{
|
||||
constructor(){
|
||||
console.log('Skirda Auth')
|
||||
}
|
||||
|
||||
static async #fetchInit(){
|
||||
const resp = await fetch(`${sk_tg_auth_api_url}/telegram/init`, {})
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Response status: ${resp.status}`)
|
||||
}
|
||||
|
||||
try {
|
||||
return await resp.json()
|
||||
} catch (error) {
|
||||
console.error(error.message)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Promise<SkirdaAuthResultResponse>
|
||||
* */
|
||||
static async Init() {
|
||||
const initResp = await SkirdaAuth.#fetchInit()
|
||||
|
||||
await shell.openExternal(initResp.redirect_url)
|
||||
|
||||
const authResult = await SkirdaAuth.#subscribe(initResp.subscribe_url)
|
||||
console.log(authResult)
|
||||
|
||||
const yggResp = await SkirdaAuth.#yggdrasilAuth(authResult.token)
|
||||
console.log(yggResp)
|
||||
// console.log(yggResp.profile)
|
||||
|
||||
return {
|
||||
'skirda_auth_resp': authResult,
|
||||
'ygg_auth_resp': yggResp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param subscribe_url
|
||||
* @returns {Promise<SkirdaAuthResultResponse>}
|
||||
*/
|
||||
static async #subscribe(subscribe_url) {
|
||||
const resp = await fetch(subscribe_url, {})
|
||||
try {
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Response status: ${resp.status}`)
|
||||
}
|
||||
return await resp.json()
|
||||
} catch (error) {
|
||||
console.error(error.message)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} token
|
||||
* @return SkirdaYggdrasilAuthResponse
|
||||
* */
|
||||
static async #yggdrasilAuth(token) {
|
||||
const ygg_auth_api_url = 'https://skirda.brzezinski.ru'
|
||||
const resp = await fetch(`${ygg_auth_api_url}/yggdrasil/skirda/authenticate`, {
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
'Authorization': token
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
return await resp.json()
|
||||
} catch (error) {
|
||||
console.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ const VIEWS = {
|
||||
landing: '#landingContainer',
|
||||
loginOptions: '#loginOptionsContainer',
|
||||
login: '#loginContainer',
|
||||
loginSkirdaAuth: '#loginSkirdaAuthContainer',
|
||||
loginSkirdaDiscord: '#loginSkirdaDiscordContainer',
|
||||
loginSkirdaTelegram: '#loginSkirdaTelegramContainer',
|
||||
loginOffline: '#loginOfflineContainer',
|
||||
|
@ -3,7 +3,19 @@
|
||||
<div class="loginOptionsMainContent">
|
||||
<h2><%- lang('loginOptions.loginOptionsTitle') %></h2>
|
||||
<div class="loginOptionActions">
|
||||
<!-- Отключенные авторизации -->
|
||||
<div class="loginOptionButtonContainer">
|
||||
<button id="loginOptionSkirdaAuth" class="loginOptionButton">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 23 23">
|
||||
<path fill="#f35325" d="M1 1h10v10H1z" />
|
||||
<path fill="#81bc06" d="M12 1h10v10H12z" />
|
||||
<path fill="#05a6f0" d="M1 12h10v10H1z" />
|
||||
<path fill="#ffba08" d="M12 12h10v10H12z" />
|
||||
</svg>
|
||||
<!-- FIXME -->
|
||||
<!-- <span><%- lang('loginOptions.loginWithSkirdaTelegram') %></span>-->
|
||||
<span>Skirda</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="loginOptionButtonContainer">
|
||||
<button id="loginOptionSkirdaTelegram" class="loginOptionButton">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 23 23">
|
||||
|
42
app/loginSkirda.ejs
Normal file
42
app/loginSkirda.ejs
Normal file
@ -0,0 +1,42 @@
|
||||
<div id="loginSkirdaAuthContainer" style="display: none;" class="Centered">
|
||||
|
||||
<!--Окно открытия браузера (ожидание ответа)-->
|
||||
<div id="loginSkirdaAuthorizationWindow">
|
||||
<div id="settingsAboutCurrentContent" class="Centered">
|
||||
<div id="settingsAboutCurrentHeadline">
|
||||
<img id="settingsAboutLogo" src="./assets/images/SealCircle.png">
|
||||
<span id="settingsAboutTitle">Authorize through Skirda Discord</span>
|
||||
</div>
|
||||
<div id="settingsAboutCurrentVersion" class="Centered">
|
||||
<span>Мы открыли браузер для дальнейшей авторизации через DiscordAAAAAAAAAAA</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="settingsAboutButtons">
|
||||
<span id="loginSkirdaAuthorizationNote">В случае, если это не произошло, откройте его самостоятельно</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Ошибка-->
|
||||
<!-- <div id="loginSkirdaAuthorizationWindow">-->
|
||||
<!-- <div id="settingsAboutCurrentContent" class="Centered">-->
|
||||
<!-- <div id="settingsAboutCurrentHeadline">-->
|
||||
<!-- <img id="settingsAboutLogo" src="./assets/images/SealCircle.png">-->
|
||||
<!-- <span id="settingsAboutTitle">Authorize through Skirda Discord</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div id="settingsAboutCurrentVersion" class="Centered">-->
|
||||
<!-- <span>Ошибка при авторизации :(</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="settingsAboutCurrentContent">-->
|
||||
<!-- <button id="loginSkirdaAuthorizationRetryButton">Повторить</button>-->
|
||||
<!-- <button class="settingsAuthAccountLogOut" style="opacity: 100%;">Отменить</button>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- </div>-->
|
||||
<!-- <div id="settingsAboutButtons">-->
|
||||
<!-- <span id="loginSkirdaAuthorizationNote">Не получается? Обратитесь к администрации проекта за помощью</span>-->
|
||||
<!-- </div> -->
|
||||
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
|
||||
<script src="./assets/js/scripts/loginSkirda.js"></script>
|
Loading…
x
Reference in New Issue
Block a user