Skip to content

Commit

Permalink
FR-12444 - remove unused code from previous implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
frontegg-david committed Jul 2, 2023
1 parent c53a9a8 commit 5d4fc82
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 104 deletions.
19 changes: 5 additions & 14 deletions Sources/FronteggSwift/FronteggAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public class FronteggAuth: ObservableObject {
@Published public var isLoading = true
@Published public var initializing = true
@Published public var showLoader = true
@Published public var pendingAppLink: URL?
@Published public var appLink: URL?
@Published public var externalLink = false
@Published public var appLink: Bool = false
public var baseUrl = ""
public var clientId = ""

Expand Down Expand Up @@ -48,15 +46,6 @@ public class FronteggAuth: ObservableObject {
}.store(in: &subscribers)


self.$pendingAppLink.sink() { pendingAppLinkValue in
if(pendingAppLinkValue != nil){
DispatchQueue.main.async {
self.appLink = pendingAppLinkValue
self.pendingAppLink = nil
}
}
}.store(in: &subscribers)

if let refreshToken = try? credentialManager.get(key: KeychainKeys.refreshToken.rawValue),
let accessToken = try? credentialManager.get(key: KeychainKeys.accessToken.rawValue) {

Expand Down Expand Up @@ -91,8 +80,7 @@ public class FronteggAuth: ObservableObject {
self.accessToken = accessToken
self.user = user
self.isAuthenticated = true
self.pendingAppLink = nil
self.appLink = nil
self.appLink = false

let offset = Double((decode["exp"] as! Int) - Int(Date().timeIntervalSince1970)) * 0.9
DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + offset) {
Expand Down Expand Up @@ -262,9 +250,12 @@ public class FronteggAuth: ObservableObject {
public func handleOpenUrl(_ url: URL) -> Bool {

if(!url.absoluteString.hasPrefix(self.baseUrl)){
self.appLink = false
return false
}

self.appLink = true

self.webAuthentication?.webAuthSession?.cancel()
self.webAuthentication = WebAuthentication()
let oauthCallback = createOauthCallbackHandler() { res in
Expand Down
65 changes: 0 additions & 65 deletions Sources/FronteggSwift/views/FronteggLoginPage.swift

This file was deleted.

22 changes: 7 additions & 15 deletions Sources/FronteggSwift/views/FronteggUIKitWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@ struct FronteggUIKitWrapper: View {
}
public var body: some View {
ZStack {
if !fronteggAuth.initializing && fronteggAuth.pendingAppLink == nil {
if(fronteggAuth.appLink != nil){
FronteggLoginPage()
} else {
if(fronteggAuth.isAuthenticated){
self.loaderView
.onAppear() {
self.navigateToAuthenticated()
}
}else {
FronteggLoginPage()
}
}
}
if fronteggAuth.showLoader || fronteggAuth.pendingAppLink != nil {
if fronteggAuth.initializing
|| fronteggAuth.showLoader
|| fronteggAuth.appLink {
self.loaderView
}else {
self.loaderView.onAppear() {
self.navigateToAuthenticated()
}
}
}
.environmentObject(fronteggAuth)
Expand Down
15 changes: 5 additions & 10 deletions Sources/FronteggSwift/views/FronteggWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@ public struct FronteggWrapper<Content: View>: View {
}
public var body: some View {
ZStack {
if !fronteggAuth.initializing && fronteggAuth.pendingAppLink == nil {
if(fronteggAuth.appLink != nil){



} else {
Group(content: content)
}
}
if fronteggAuth.showLoader || fronteggAuth.pendingAppLink != nil {
if fronteggAuth.initializing
|| fronteggAuth.showLoader
|| fronteggAuth.appLink {
self.loaderView
} else {
Group(content: content)
}
}
.environmentObject(fronteggAuth)
Expand Down

0 comments on commit 5d4fc82

Please sign in to comment.