public object assertPermission(ScriptScopeContext scope, string permission) => assertRole(scope, permission, null);
public object ifNotAuthenticated(ScriptScopeContext scope) => !isAuthenticated(scope) ? (object)IgnoreResult.Value : StopExecution.Value;
public object hasPermission(ScriptScopeContext scope, string permission) => userSession(scope)?.HasPermission(permission, req(scope).TryResolve <IAuthRepository>()) == true;
public object assertRole(ScriptScopeContext scope, string role) => assertRole(scope, role, null);
public IUserAuth tryAuthenticate(ScriptScopeContext scope, IAuthRepository authRepo, string userName, string password) => authRepo.TryAuthenticate(userName, password, out var ret) ? ret : null;
public override Task WriteAsync(ScriptScopeContext scope, PageBlockFragment block, CancellationToken token) => WriteAsync((TemplateScopeContext)scope, block, token);
public string userProfileUrl(ScriptScopeContext scope) => req(scope).GetSession().GetProfileUrl();
public IAuthRepository authRepo(ScriptScopeContext scope) => HostContext.AppHost.GetAuthRepository(req(scope));
public object getUserSession(ScriptScopeContext scope) => req(scope).GetSession();
public IAuthSession userSession(ScriptScopeContext scope) => req(scope).GetSession();
public object sendToAutoQuery(ScriptScopeContext scope, object dto, string requestName, object options) { try { if (requestName == null) { throw new ArgumentNullException(nameof(requestName)); } if (dto == null) { throw new ArgumentNullException(nameof(dto)); } var requestType = appHost.Metadata.GetOperationType(requestName); if (requestType == null) { throw new ArgumentException("Request DTO not found: " + requestName); } if (requestType.HasInterface(typeof(IQueryDb))) { var ssFilter = Context.ScriptMethods.FirstOrDefault(x => x is IAutoQueryDbFilters) as IAutoQueryDbFilters; if (ssFilter == null) { throw new NotImplementedException("sendToAutoQuery RDBMS requires TemplateAutoQueryFilters"); } return(ssFilter.sendToAutoQuery(scope, dto, requestName, options)); } var autoQuery = appHost.TryResolve <IAutoQueryData>(); if (autoQuery == null) { throw new NotSupportedException("The AutoQueryDataFeature plugin is not registered."); } var objDictionary = dto is Dictionary <string, object> od ? od : null; var requestDto = objDictionary != null ? objDictionary.FromObjectDictionary(requestType) : dto.GetType() == requestType ? dto : dto.ConvertTo(requestType); if (!(requestDto is IQueryData aqDto)) { throw new ArgumentException("Request DTO is not an AutoQuery Data DTO: " + requestName); } var reqParams = objDictionary?.ToStringDictionary() ?? TypeConstants.EmptyStringDictionary; var q = autoQuery.CreateQuery(aqDto, reqParams, req(scope)); var response = autoQuery.Execute(aqDto, q); return(response); } catch (Exception ex) { if (Log.IsDebugEnabled) { Log.Error(ex.Message, ex); } throw new StopFilterExecutionException(scope, options, ex); } }
public object sendToAutoQuery(ScriptScopeContext scope, object dto, string requestName) => sendToAutoQuery(scope, dto, requestName, null);
public object sendToAutoQuery(ScriptScopeContext scope, string requestName) => sendToAutoQuery(scope, TypeConstants.EmptyObjectDictionary, requestName, null);
public object endIfAuthenticated(ScriptScopeContext scope, object value) => !isAuthenticated(scope) ? value : StopExecution.Value;
public HashSet <string> userAttributes(ScriptScopeContext scope) => req(scope).GetUserAttributes();
public IHttpRequest getHttpRequest(ScriptScopeContext scope) => req(scope);
public bool isAuthenticated(ScriptScopeContext scope) { var authSession = userSession(scope); return(authSession?.IsAuthenticated == true); }
internal IHttpRequest req(ScriptScopeContext scope) => scope.GetValue("Request") as IHttpRequest;
public object hasRole(ScriptScopeContext scope, string role) => userSession(scope)?.HasRole(role, req(scope).TryResolve <IAuthRepository>()) == true;
public object resolveUrl(ScriptScopeContext scope, string virtualPath) => req(scope).ResolveAbsoluteUrl(virtualPath);
public override object Evaluate(ScriptScopeContext scope) => this;