Skip to content

Commit

Permalink
Added keepUserAfterReinstall property to Frontegg.plist
Browse files Browse the repository at this point in the history
  • Loading branch information
“oleksii-minaiev” committed Sep 18, 2024
1 parent b32ded3 commit 43b60aa
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,22 @@ struct SelectRegionView: View {
}
```

## Logout User after application was uninstall

If you want that user not to keep logged in after reinstalling an application please add the `keepUserAfterReinstall` property to the `Frontegg.plist` file:

```xml
<plist version="1.0">
<dict>
<key>keepUserAfterReinstall</key>
<false/>
...
</dict>
</plist>
```

By default `keepUserAfterReinstall` is `true`.

## Login with ASWebAuthenticationSession

Starting from version 1.2.9, the Frontegg SDK has introduced support for ASWebAuthenticationSession, enhancing the login
Expand Down
16 changes: 16 additions & 0 deletions Sources/FronteggSwift/FronteggApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class FronteggApp {
self.handleLoginWithSocialLogin = bridgeOptions["loginWithSocialLogin"] ?? true
self.handleLoginWithSSO = bridgeOptions["loginWithSSO"] ?? false

if FronteggApp.clearKeychain() {
self.credentialManager.clear()
}

/**
lateInit used for react-native and ionic-capacitor initialization
*/
Expand Down Expand Up @@ -179,4 +183,16 @@ public class FronteggApp {
logger.info("Frontegg Initialized succcessfully (region: \(regionKey))")
}

private static func clearKeychain() -> Bool {
if PlistHelper.keepUserAfterReinstall() {
return false
}

let userDefaults = UserDefaults.standard
if !userDefaults.bool(forKey: "IsFronteggFirstApplicationRun") {
userDefaults.set(true, forKey: "IsFronteggFirstApplicationRun")
return true
}
return false
}
}
11 changes: 10 additions & 1 deletion Sources/FronteggSwift/utils/PlistHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,16 @@ struct PlistHelper {
return false
}


public static func keepUserAfterReinstall() -> Bool {
let bundle = Bundle.main;
if let path = bundle.path(forResource: "Frontegg", ofType: "plist"),
let values = NSDictionary(contentsOfFile: path) as? [String: Any],
let value = values["keepUserAfterReinstall"] as? Bool {
return value
}
return true
}

public static func getKeychainService() -> String {
let bundle = Bundle.main;
if let path = bundle.path(forResource: "Frontegg", ofType: "plist"),
Expand Down
2 changes: 2 additions & 0 deletions demo/demo/Frontegg.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keepUserAfterReinstall</key>
<true/>
<key>baseUrl</key>
<string>https://auth.davidantoon.me</string>
<key>clientId</key>
Expand Down

0 comments on commit 43b60aa

Please sign in to comment.