Skip to content

Commit

Permalink
fixed edge case when not showing xcreds login when logging out
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Nov 12, 2022
1 parent 570576b commit 3447f7b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion XCredsLoginPlugIn/LoginProgressWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LoginProgressWindowController: NSWindowController {

NotificationCenter.default.addObserver(forName: NSNotification.Name("hideProgress"), object:nil, queue: nil) { notification in

TCSLogWithMark("gotnotification")
TCSLogWithMark("Got notified to hide progress.")
self.window?.close()

}
Expand Down
8 changes: 5 additions & 3 deletions XCredsLoginPlugIn/Mechanisms/XCredsLoginMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,17 @@ import Cocoa
return
}
let isReturning = FileManager.default.fileExists(atPath: "/tmp/xcreds_return")
TCSLogWithMark("Verifying if we should show cloud login.")

if isReturning == false, UserDefaults.standard.bool(forKey: PrefKeys.shouldShowCloudLoginByDefault.rawValue) == false {
setContextString(type: kAuthorizationEnvironmentUsername, value: SpecialUsers.standardLoginWindow.rawValue)
TCSLogWithMark("marking to show standard login window")

allowLogin()
return
}
if isReturning == true {
try? FileManager.default.removeItem(atPath: "/tmp/xcreds_return")
}
TCSLogWithMark("Showing XCreds Login Window")

NSApp.activate(ignoringOtherApps: true)

webViewController = LoginWebViewController(windowNibName: NSNib.Name("LoginWebView"))
Expand Down
13 changes: 12 additions & 1 deletion XCredsLoginPlugIn/Mechanisms/XCredsPowerControlMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ class XCredsPowerControlMechanism: XCredsBaseMechanism {

@objc override func run() {
TCSLogWithMark("PowerControl mech starting")

if FileManager.default.fileExists(atPath: "/tmp/xcreds_return")==true{
TCSLogWithMark("xcreds_return exists, removing")

do{
try FileManager.default.removeItem(atPath: "/tmp/xcreds_return")
}
catch {
TCSLogWithMark("Error removing xcreds_return \(error.localizedDescription)")
}
}

if AuthorizationDBManager.shared.rightExists(right: "loginwindow:login"){
TCSLogWithMark("setting standard login back to XCreds login")
let _ = AuthorizationDBManager.shared.replace(right:"loginwindow:login", withNewRight: "XCredsLoginPlugin:LoginWindow")
Expand All @@ -32,7 +44,6 @@ class XCredsPowerControlMechanism: XCredsBaseMechanism {
}



switch userName {
case SpecialUsers.sleep.rawValue:
TCSLogWithMark("Sleeping system.")
Expand Down
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3327;
CURRENT_PROJECT_VERSION = 3335;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -924,7 +924,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3327;
CURRENT_PROJECT_VERSION = 3335;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -983,7 +983,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3327;
CURRENT_PROJECT_VERSION = 3335;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1013,7 +1013,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3327;
CURRENT_PROJECT_VERSION = 3335;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1156,7 +1156,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3327;
CURRENT_PROJECT_VERSION = 3335;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -1185,7 +1185,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3327;
CURRENT_PROJECT_VERSION = 3335;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
Binary file not shown.

0 comments on commit 3447f7b

Please sign in to comment.