Skip to content

Commit

Permalink
fix login with action url
Browse files Browse the repository at this point in the history
  • Loading branch information
frontegg-david committed Jan 10, 2024
1 parent e3684ab commit 8b3ef08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions Sources/FronteggSwift/embedded/EmbeddedLoginModal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public struct EmbeddedLoginModal: View {
&& fronteggAuth.isAuthenticated {

DefaultLoader().onAppear() {

VCHolder.shared.vc?.presentedViewController?.dismiss(animated: true)
VCHolder.shared.vc = nil
}
Expand Down
27 changes: 16 additions & 11 deletions Sources/FronteggSwift/utils/AuthorizeUrlGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,30 @@ public class AuthorizeUrlGenerator {

if(loginAction != nil){
queryParams.append(URLQueryItem(name: "login_direct_action", value: loginAction))
queryParams.append(URLQueryItem(name: "prompt", value: "login"))

authorizeUrl.queryItems = queryParams

if let url = authorizeUrl.url{
return (url, codeVerifier)
} else {
logger.error("Unkonwn error occured while generating authorize url, baseUrl: \(baseUrl)")
fatalError("Failed to generate authorize url")
}
}

authorizeUrl.queryItems = queryParams

if let url = authorizeUrl.url{
logger.trace("Generated url: \(url.absoluteString)")

// if let encodedURL = url.absoluteString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
var loginUrl = URLComponents(string: baseUrl)!
var loginUrl = URLComponents(string: baseUrl)!

loginUrl.path = "/oauth/logout"
loginUrl.queryItems = [
URLQueryItem(name: "post_logout_redirect_uri", value: url.absoluteString),
]
return (loginUrl.url!, codeVerifier)
// } else {
// logger.error("Failed to parse the generated url, baseUrl: \(baseUrl)")
// fatalError("Failed to generate authorize url")
// }
loginUrl.path = "/oauth/logout"
loginUrl.queryItems = [
URLQueryItem(name: "post_logout_redirect_uri", value: url.absoluteString),
]
return (loginUrl.url!, codeVerifier)
} else {
logger.error("Unkonwn error occured while generating authorize url, baseUrl: \(baseUrl)")
fatalError("Failed to generate authorize url")
Expand Down

0 comments on commit 8b3ef08

Please sign in to comment.