private bool IsValidRequest() { Thread.Sleep(2000); if (this.Context == null) { this.Clients.Caller.getNotification(I18N.AccessIsDenied); return(false); } string tenant = AppUsers.GetTenant(); long loginId = HubAuthorizationManger.GetLoginIdAsync(tenant, this.Context).GetAwaiter().GetResult(); var meta = AppUsers.GetCurrent(tenant, loginId); if (loginId <= 0) { this.Clients.Caller.getNotification(I18N.AccessIsDenied); return(false); } if (!meta.IsAdministrator) { return(false); } return(true); }
public void PerformEod() { if (!this.IsValidRequest()) { this.Clients.Caller.getNotification(I18N.AccessIsDenied, I18N.AccessIsDenied); return; } var operation = new EodPerformer(); operation.NotificationReceived += this.EOD_NotificationReceived; string tenant = AppUsers.GetTenant(); long loginId = HubAuthorizationManger.GetLoginIdAsync(tenant, this.Context).GetAwaiter().GetResult(); operation.Perform(tenant, loginId); }
public override Task OnConnected() { string connectionId = this.Context.ConnectionId; string tenant = TenantConvention.GetTenant(this.Context.Request.Url.DnsSafeHost); long loginId = HubAuthorizationManger.GetLoginIdAsync(tenant, this.Context).GetAwaiter().GetResult(); var model = AppUsers.GetCurrentAsync(tenant, loginId).GetAwaiter().GetResult().Adapt <UserInfo>(); if (model == null) { return(base.OnConnected()); } model.Tenant = tenant; Connections[connectionId] = model; return(base.OnConnected()); }
private bool IsValidRequest() { if (this.Context == null) { this.Clients.Caller.getNotification("Access is denied."); return(false); } string tenant = AppUsers.GetTenant(); long loginId = HubAuthorizationManger.GetLoginIdAsync(tenant, this.Context).GetAwaiter().GetResult(); var meta = AppUsers.GetCurrent(tenant, loginId); if (loginId <= 0) { this.Clients.Caller.getNotification("Access is denied."); return(false); } return(meta.IsAdministrator); }