diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-16 21:16:56 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-16 21:16:56 -0800 |
commit | 6151cb6bb26ddf863f09e0990921e86bba44fd92 (patch) | |
tree | 67dbcc5d6f6cdd1898a1f8deadfc61baad2ee6dc | |
parent | 828e5bb715ff3ec81e79840a1cb7835bce81120e (diff) | |
download | DotNetOpenAuth-6151cb6bb26ddf863f09e0990921e86bba44fd92.zip DotNetOpenAuth-6151cb6bb26ddf863f09e0990921e86bba44fd92.tar.gz DotNetOpenAuth-6151cb6bb26ddf863f09e0990921e86bba44fd92.tar.bz2 |
Fixed unhandled exception for returning users introduced by UTC date/time enforcement code that was recently introduced.
5 files changed, 14 insertions, 14 deletions
diff --git a/projecttemplates/RelyingPartyLogic/Model.AuthenticationToken.cs b/projecttemplates/RelyingPartyLogic/Model.AuthenticationToken.cs index f629bf6..d6564da 100644 --- a/projecttemplates/RelyingPartyLogic/Model.AuthenticationToken.cs +++ b/projecttemplates/RelyingPartyLogic/Model.AuthenticationToken.cs @@ -28,15 +28,11 @@ } partial void OnLastUsedUtcChanging(DateTime value) { - if (value.Kind != DateTimeKind.Utc) { - throw new ArgumentException("DateTime must be given in UTC time."); - } + Utilities.VerifyThrowNotLocalTime(value); } partial void OnCreatedOnUtcChanging(DateTime value) { - if (value.Kind != DateTimeKind.Utc) { - throw new ArgumentException("DateTime must be given in UTC time."); - } + Utilities.VerifyThrowNotLocalTime(value); } } } diff --git a/projecttemplates/RelyingPartyLogic/Model.IssuedAccessToken.cs b/projecttemplates/RelyingPartyLogic/Model.IssuedAccessToken.cs index d966baf..25d983b 100644 --- a/projecttemplates/RelyingPartyLogic/Model.IssuedAccessToken.cs +++ b/projecttemplates/RelyingPartyLogic/Model.IssuedAccessToken.cs @@ -66,8 +66,8 @@ namespace RelyingPartyLogic { } partial void OnExpirationDateUtcChanging(DateTime? value) { - if (value.HasValue && value.Value.Kind != DateTimeKind.Utc) { - throw new ArgumentException("DateTime must be given in UTC time."); + if (value.HasValue) { + Utilities.VerifyThrowNotLocalTime(value.Value); } } } diff --git a/projecttemplates/RelyingPartyLogic/Model.IssuedToken.cs b/projecttemplates/RelyingPartyLogic/Model.IssuedToken.cs index aab1fc1..5e10178 100644 --- a/projecttemplates/RelyingPartyLogic/Model.IssuedToken.cs +++ b/projecttemplates/RelyingPartyLogic/Model.IssuedToken.cs @@ -20,9 +20,7 @@ namespace RelyingPartyLogic { } partial void OnCreatedOnUtcChanging(DateTime value) { - if (value.Kind != DateTimeKind.Utc) { - throw new ArgumentException("DateTime must be given in UTC time."); - } + Utilities.VerifyThrowNotLocalTime(value); } } } diff --git a/projecttemplates/RelyingPartyLogic/Model.User.cs b/projecttemplates/RelyingPartyLogic/Model.User.cs index 51fd38b..b47cd2f 100644 --- a/projecttemplates/RelyingPartyLogic/Model.User.cs +++ b/projecttemplates/RelyingPartyLogic/Model.User.cs @@ -19,9 +19,7 @@ namespace RelyingPartyLogic { } partial void OnCreatedOnUtcChanging(DateTime value) { - if (value.Kind != DateTimeKind.Utc) { - throw new ArgumentException("DateTime must be given in UTC time."); - } + Utilities.VerifyThrowNotLocalTime(value); } partial void OnEmailAddressChanged() { diff --git a/projecttemplates/RelyingPartyLogic/Utilities.cs b/projecttemplates/RelyingPartyLogic/Utilities.cs index 02eb273..affbe26 100644 --- a/projecttemplates/RelyingPartyLogic/Utilities.cs +++ b/projecttemplates/RelyingPartyLogic/Utilities.cs @@ -60,5 +60,13 @@ GO serverConnection.Disconnect(); } } + + internal static void VerifyThrowNotLocalTime(DateTime value) { + // When we want UTC time, we have to accept Unspecified kind + // because that's how it is set to us in the database. + if (value.Kind == DateTimeKind.Local) { + throw new ArgumentException("DateTime must be given in UTC time but was " + value.Kind.ToString()); + } + } } } |