diff --git a/Yavsc.Server/Models/Auth/OAuth2Tokens.cs b/Yavsc.Server/Models/Auth/OAuth2Tokens.cs
index 74551263..89963ed4 100644
--- a/Yavsc.Server/Models/Auth/OAuth2Tokens.cs
+++ b/Yavsc.Server/Models/Auth/OAuth2Tokens.cs
@@ -1,7 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
-namespace Yavsc.Models.OAuth
+namespace Yavsc.Models.Auth
{
///
/// OffLine OAuth2 Token
diff --git a/Yavsc.Server/Models/Auth/UserCredentials.cs b/Yavsc.Server/Models/Auth/UserCredentials.cs
index 96e02ad3..88a6ae55 100644
--- a/Yavsc.Server/Models/Auth/UserCredentials.cs
+++ b/Yavsc.Server/Models/Auth/UserCredentials.cs
@@ -1,6 +1,4 @@
-using Yavsc.Models.OAuth;
-
namespace Yavsc.Models.Auth {
public class UserCredential {
@@ -19,4 +17,4 @@ namespace Yavsc.Models.Auth {
}
}
-}
\ No newline at end of file
+}
diff --git a/Yavsc/Controllers/Haircut/HairCutCommandController.cs b/Yavsc/Controllers/Haircut/HairCutCommandController.cs
index d4cf2d83..25769e59 100644
--- a/Yavsc/Controllers/Haircut/HairCutCommandController.cs
+++ b/Yavsc/Controllers/Haircut/HairCutCommandController.cs
@@ -89,10 +89,12 @@ namespace Yavsc.Controllers
paymentOk = true;
command.ValidationDate = DateTime.Now;
}
+ else _logger.LogError
+ ("This Command were yet validated, and is now paied one more ...");
}
await _context.SaveChangesAsync(User.GetUserId());
SetViewBagPaymentUrls(id);
- if (command.PerformerProfile.AcceptPublicContact && paymentOk)
+ if (paymentOk)
{
MessageWithPayloadResponse grep = null;
var yaev = command.CreatePaymentEvent(paymentInfo, _localizer);
@@ -118,10 +120,6 @@ namespace Yavsc.Controllers
yaev.CreateBody()
);
}
- else
- {
- // TODO if (AcceptProContact) try & find a bookmaker to send him this query
- }
ViewData["Notify"] = new List {
new Notification {
diff --git a/Yavsc/Helpers/GoogleHelpers.cs b/Yavsc/Helpers/GoogleOAuthHelpers.cs
similarity index 99%
rename from Yavsc/Helpers/GoogleHelpers.cs
rename to Yavsc/Helpers/GoogleOAuthHelpers.cs
index 703a06ed..75867cfd 100644
--- a/Yavsc/Helpers/GoogleHelpers.cs
+++ b/Yavsc/Helpers/GoogleOAuthHelpers.cs
@@ -47,9 +47,6 @@ namespace Yavsc.Helpers
///
public static class GoogleHelpers
{
-
-
-
public static async Task GetCredentialForApi(IEnumerable scopes)
{
GoogleCredential credential = await GoogleCredential.GetApplicationDefaultAsync();
diff --git a/Yavsc/Helpers/GoogleStoreHelpers.cs b/Yavsc/Helpers/GoogleStoreHelpers.cs
new file mode 100644
index 00000000..b8ee7441
--- /dev/null
+++ b/Yavsc/Helpers/GoogleStoreHelpers.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNet.Identity.EntityFramework;
+using Microsoft.Data.Entity;
+using System.Threading;
+using Newtonsoft.Json.Linq;
+
+namespace Yavsc.Helpers.Google {
+ using Yavsc.Models;
+ using Yavsc.Models.Auth;
+ public static class GoogleStoreHelper {
+
+ public static Task GetTokensAsync(this ApplicationDbContext context, string googleUserId)
+ {
+ if (string.IsNullOrEmpty(googleUserId))
+ {
+ throw new ArgumentException("email MUST have a value");
+ }
+
+ var item = context.Tokens.FirstOrDefault(x => x.UserId == googleUserId);
+ // TODO Refresh token
+
+ return Task.FromResult(item);
+ }
+
+ public static Task StoreTokenAsync(this ApplicationDbContext context, string googleUserId, JObject response, string accessToken,
+ string tokenType, string refreshToken, string expiresIn
+ )
+ {
+ if (string.IsNullOrEmpty(googleUserId))
+ {
+ throw new ArgumentException("googleUserId MUST have a value");
+ }
+
+ var item = context.Tokens.SingleOrDefaultAsync(x => x.UserId == googleUserId).Result;
+ if (item == null)
+ {
+ context.Tokens.Add(new OAuth2Tokens
+ {
+ TokenType = "Bearer",
+ AccessToken = accessToken,
+ RefreshToken = refreshToken,
+ Expiration = DateTime.Now.AddSeconds(int.Parse(expiresIn)),
+ UserId = googleUserId
+ });
+ }
+ else
+ {
+ item.AccessToken = accessToken;
+ item.Expiration = DateTime.Now.AddMinutes(int.Parse(expiresIn));
+ if (refreshToken != null)
+ item.RefreshToken = refreshToken;
+ context.Tokens.Update(item);
+ }
+ context.SaveChanges(googleUserId);
+ return Task.FromResult(0);
+ }
+ }
+}
diff --git a/Yavsc/Models/ApplicationDbContext.cs b/Yavsc/Models/ApplicationDbContext.cs
index 4e988be4..24764bc3 100644
--- a/Yavsc/Models/ApplicationDbContext.cs
+++ b/Yavsc/Models/ApplicationDbContext.cs
@@ -64,7 +64,7 @@ namespace Yavsc.Models
builder.Entity().HasKey(o => new { o.Code, o.CodeScrutin });
builder.Entity().Property(n => n.icon).HasDefaultValue("exclam");
builder.Entity().HasKey(p => new { room = p.ChannelName, user = p.ChatUserConnectionId });
-
+
foreach (var et in builder.Model.GetEntityTypes())
{
if (et.ClrType.GetInterface("IBaseTrackedEntity") != null)
@@ -137,56 +137,6 @@ namespace Yavsc.Models
public DbSet Services { get; set; }
public DbSet Products { get; set; }
-
- public Task GetTokensAsync(string googleUserId)
- {
- if (string.IsNullOrEmpty(googleUserId))
- {
- throw new ArgumentException("email MUST have a value");
- }
-
- using (var context = new ApplicationDbContext())
- {
- var item = this.Tokens.FirstOrDefault(x => x.UserId == googleUserId);
- // TODO Refresh token
-
- return Task.FromResult(item);
- }
- }
-
- public Task StoreTokenAsync(string googleUserId, JObject response, string accessToken,
- string tokenType, string refreshToken, string expiresIn
- )
- {
- if (string.IsNullOrEmpty(googleUserId))
- {
- throw new ArgumentException("googleUserId MUST have a value");
- }
-
- var item = this.Tokens.SingleOrDefaultAsync(x => x.UserId == googleUserId).Result;
- if (item == null)
- {
- Tokens.Add(new OAuth2Tokens
- {
- TokenType = "Bearer", // FIXME why value.TokenType would be null?
- AccessToken = accessToken,
- RefreshToken = refreshToken,
- Expiration = DateTime.Now.AddSeconds(int.Parse(expiresIn)),
- UserId = googleUserId
- });
- }
- else
- {
- item.AccessToken = accessToken;
- item.Expiration = DateTime.Now.AddMinutes(int.Parse(expiresIn));
- if (refreshToken != null)
- item.RefreshToken = refreshToken;
- Tokens.Update(item);
- }
- SaveChanges(googleUserId);
- return Task.FromResult(0);
- }
-
Client FindApplication(string clientId)
{
return Applications.FirstOrDefault(
diff --git a/Yavsc/Startup/Startup.OAuth.cs b/Yavsc/Startup/Startup.OAuth.cs
index 36b20677..1f7cfb67 100644
--- a/Yavsc/Startup/Startup.OAuth.cs
+++ b/Yavsc/Startup/Startup.OAuth.cs
@@ -24,6 +24,8 @@ namespace Yavsc
using Auth;
using Extensions;
using Models;
+ using Helpers.Google;
+
public partial class Startup
{
public static CookieAuthenticationOptions ExternalCookieAppOptions { get; private set; }
diff --git a/Yavsc/Views/HairCutCommand/HairCut.cshtml b/Yavsc/Views/HairCutCommand/HairCut.cshtml
index 86794642..b2a3b6ac 100644
--- a/Yavsc/Views/HairCutCommand/HairCut.cshtml
+++ b/Yavsc/Views/HairCutCommand/HairCut.cshtml
@@ -280,9 +280,6 @@
-
-
-
@Html.HiddenFor(model=>model.Location.Latitude)
@Html.HiddenFor(model=>model.Location.Longitude)