-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed regression for password change not capturing new password on azure
- Loading branch information
Showing
7 changed files
with
193 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// LicenseChecker.swift | ||
// XCreds | ||
// | ||
// Created by Timothy Perfitt on 3/28/23. | ||
// | ||
|
||
import Cocoa | ||
|
||
class LicenseChecker: NSObject { | ||
enum LicenseState { | ||
case valid | ||
case invalid | ||
case trial(Int) | ||
case trialExpired | ||
case expired | ||
} | ||
|
||
func currentLicenseState() -> LicenseState { | ||
let trialDays = 14 | ||
|
||
if UserDefaults.standard.value(forKey: "tts") == nil { | ||
UserDefaults.standard.setValue(Date(), forKey: "tts") | ||
} | ||
let firstLaunchDate = UserDefaults.standard.value(forKey: "tts") as? Date | ||
|
||
var trialState = LicenseState.trialExpired | ||
if let firstLaunchDate = firstLaunchDate { | ||
let secondsPassed = Date().timeIntervalSince(firstLaunchDate) | ||
let trialDaysLeft=trialDays-(Int(secondsPassed)/(24*60*60)); | ||
|
||
if secondsPassed<Double(24*60*60*trialDays) { | ||
trialState = .trial(trialDaysLeft) | ||
} | ||
|
||
} | ||
let check = TCSLicenseCheck() | ||
let status = check.checkLicenseStatus("com.twocanoes.xcreds", withExtension: "") | ||
|
||
switch status { | ||
|
||
case .valid: | ||
TCSLogWithMark("valid license") | ||
return .valid | ||
case .expired: | ||
TCSLogWithMark("expired license") | ||
return trialState | ||
|
||
case .invalid: | ||
TCSLogWithMark("license invalid") | ||
return trialState | ||
case .unset: | ||
TCSLogWithMark("No License") | ||
return trialState | ||
default: | ||
TCSLogWithMark("invalid license") | ||
return trialState | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+6.34 KB
(100%)
...deproj/project.xcworkspace/xcuserdata/tperfitt.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
Oops, something went wrong.