client: fix cloud/local login redirect flow

This commit is contained in:
Koushik Dutta
2022-09-13 17:28:50 -07:00
parent 479bc55b75
commit a886847e39
3 changed files with 11 additions and 5 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/client",
"version": "1.0.50",
"version": "1.0.53",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/client",
"version": "1.0.50",
"version": "1.0.53",
"license": "ISC",
"dependencies": {
"@scrypted/types": "^0.0.88",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/client",
"version": "1.0.50",
"version": "1.0.53",
"description": "",
"main": "dist/packages/client/src/index.js",
"scripts": {

View File

@@ -119,9 +119,15 @@ export class ScryptedClientLoginError extends Error {
}
}
export function redirectScryptedLogin(baseUrl?: string) {
export function redirectScryptedLogin(options?: {
redirect?: string, baseUrl?: string
}) {
let { baseUrl, redirect } = options || {};
baseUrl = baseUrl || '';
window.location.href = `${baseUrl}/endpoint/@scrypted/core/public/?redirect_uri=${encodeURIComponent(window.location.href)}`;
redirect = redirect || `${baseUrl}/endpoint/@scrypted/core/public/`
const redirect_uri = `${redirect}?redirect_uri=${encodeURIComponent(window.location.href)}`;
console.log('redirect_uri', redirect_uri);
window.location.href = redirect_uri;
}
export async function redirectScryptedLogout(baseUrl?: string) {