Skip to content

Commit

Permalink
fixed shouldShowCloudLoginByDefault not working
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Nov 12, 2022
1 parent 1d37d90 commit 570576b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
8 changes: 6 additions & 2 deletions XCreds Login Overlay/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import AppKit
@main
struct MyMain {
static func main() -> Void {
sleep(5)
sleep(15)
let _ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
}
}
Expand Down Expand Up @@ -38,6 +38,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

if AuthorizationDBManager.shared.rightExists(right: "loginwindow:login"){
TCSLogWithMark("setting standard login back to XCreds login")
try? "".write(toFile: "/tmp/xcreds_return", atomically: false, encoding: .utf8)
let _ = AuthorizationDBManager.shared.replace(right:"loginwindow:login", withNewRight: "XCredsLoginPlugin:LoginWindow")
let _ = cliTask("/usr/bin/killall loginwindow")

Expand Down Expand Up @@ -70,7 +71,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
*/
func applicationDidFinishLaunching(_ aNotification: Notification) {


var statusWindowRect=window.frame
let screenRect = NSScreen.screens[0].visibleFrame
statusWindowRect.size.width=screenRect.size.width
Expand All @@ -80,6 +80,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
window.hidesOnDeactivate=false
window.isOpaque=false
window.level = .modalPanel
Timer.scheduledTimer(withTimeInterval: 15, repeats: true) { timer in
NSApp.activate(ignoringOtherApps: true)
self.window.orderFrontRegardless()
}
NSApp.activate(ignoringOtherApps: true)
window.orderFrontRegardless()

Expand Down
7 changes: 5 additions & 2 deletions XCredsLoginPlugIn/Mechanisms/XCredsLoginMechanism.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ import Cocoa
allowLogin()
return
}
if UserDefaults.standard.bool(forKey: PrefKeys.shouldShowCloudLoginByDefault.rawValue) == false {
let isReturning = FileManager.default.fileExists(atPath: "/tmp/xcreds_return")
if isReturning == false, UserDefaults.standard.bool(forKey: PrefKeys.shouldShowCloudLoginByDefault.rawValue) == false {
setContextString(type: kAuthorizationEnvironmentUsername, value: SpecialUsers.standardLoginWindow.rawValue)

allowLogin()
return
}

if isReturning == true {
try? FileManager.default.removeItem(atPath: "/tmp/xcreds_return")
}
NSApp.activate(ignoringOtherApps: true)

webViewController = LoginWebViewController(windowNibName: NSNib.Name("LoginWebView"))
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 = 3318;
CURRENT_PROJECT_VERSION = 3327;
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 = 3318;
CURRENT_PROJECT_VERSION = 3327;
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 = 3318;
CURRENT_PROJECT_VERSION = 3327;
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 = 3318;
CURRENT_PROJECT_VERSION = 3327;
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 = 3318;
CURRENT_PROJECT_VERSION = 3327;
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 = 3318;
CURRENT_PROJECT_VERSION = 3327;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
Binary file not shown.

0 comments on commit 570576b

Please sign in to comment.