TF-624 Create login-callback.html to redirect url on browser
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
|
||||
import 'package:core/utils/build_utils.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class OIDCConfiguration with EquatableMixin {
|
||||
static const redirectOidc = 'teammail.mobile://oauthredirect';
|
||||
static const redirectOidcMobile = 'teammail.mobile://oauthredirect';
|
||||
static const redirectOidcWeb = 'http://localhost:3000/login-callback.html';
|
||||
static const wellKnownOpenId = '.well-known/openid-configuration';
|
||||
|
||||
final String authority;
|
||||
final String clientId;
|
||||
final String redirectUrl = redirectOidc;
|
||||
final List<String> scopes;
|
||||
|
||||
OIDCConfiguration({
|
||||
@@ -24,6 +25,8 @@ class OIDCConfiguration with EquatableMixin {
|
||||
}
|
||||
}
|
||||
|
||||
String get redirectUrl => BuildUtils.isWeb ? redirectOidcWeb : redirectOidcMobile;
|
||||
|
||||
String get clientIdHash => clientId.hashCode.toString();
|
||||
|
||||
@override
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script>
|
||||
const AUTH_DESTINATION_KEY = "auth_destination_url";
|
||||
const AUTH_RESPONSE_KEY = "auth_info";
|
||||
|
||||
window.onload = function () {
|
||||
if (window.opener && window.opener !== window) { //Used when working as a popup. Uses post message to respond to the parent window
|
||||
var parent = window.opener ?? window.parent;
|
||||
parent.postMessage(location.href, "*");
|
||||
} else { //Used for redirect loop functionality.
|
||||
//Get the original page destination
|
||||
const destination = sessionStorage.getItem(AUTH_DESTINATION_KEY || "/");
|
||||
sessionStorage.removeItem(AUTH_DESTINATION_KEY);
|
||||
//Store the current window location that will be used to get the information for authentication
|
||||
sessionStorage.setItem(AUTH_RESPONSE_KEY, window.location);
|
||||
|
||||
//Redirect to where we're going so that we can restore state completely
|
||||
location.assign(destination);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user