コード例 #1
0
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            var context = new Context();
            var api     = Forms.String().Deserialize <Api>();

            if (api?.ApiKey.IsNullOrEmpty() == false)
            {
                var userModel = new UserModel().Get(
                    context: context,
                    ss: null,
                    where : Rds.UsersWhere()
                    .ApiKey(api.ApiKey)
                    .Disabled(0));
                if (userModel.AccessStatus != Databases.AccessStatuses.Selected)
                {
                    filterContext.Result = ApiResults.Unauthorized();
                }
                else
                {
                    userModel.SetSession();
                    if (!Contract.Api(context: context))
                    {
                        Sessions.Abandon();
                        filterContext.Result = ApiResults.BadRequest();
                    }
                }
            }
            else if (!Sessions.LoggedIn())
            {
                filterContext.Result = ApiResults.Unauthorized();
            }
        }
コード例 #2
0
 private static HtmlBuilder AccountMenu(this HtmlBuilder hb)
 {
     return(hb.Ul(id: "AccountMenu", css: "menu", action: () => hb
                  .Li(action: () => hb
                      .A(
                          href: Locations.Logout(),
                          action: () => hb
                          .Span(css: "ui-icon ui-icon-locked")
                          .Text(text: Displays.Logout())))
                  .Li(
                      action: () => hb
                      .A(
                          href: Locations.Edit("Users", Sessions.UserId()),
                          action: () => hb
                          .Span(css: "ui-icon ui-icon-wrench")
                          .Text(text: Displays.EditProfile())),
                      _using: Parameters.Service.ShowProfiles)
                  .Li(
                      action: () => hb
                      .A(
                          href: Locations.Get("Users", "EditApi"),
                          action: () => hb
                          .Span(css: "ui-icon ui-icon-link")
                          .Text(text: Displays.ApiSettings())),
                      _using: Contract.Api())
                  .Li(action: () => hb
                      .A(
                          href: Parameters.General.HtmlUsageGuideUrl,
                          target: "_blank",
                          action: () => hb
                          .Span(css: "ui-icon ui-icon-help")
                          .Text(text: Displays.UsageGuide())))
                  .Li(action: () => hb
                      .A(
                          href: Parameters.General.HtmlBlogUrl,
                          target: "_blank",
                          action: () => hb
                          .Span(css: "ui-icon ui-icon-info")
                          .Text(text: Displays.Blog())))
                  .Li(action: () => hb
                      .A(
                          href: Parameters.General.HtmlCopyrightUrl,
                          target: "_blank",
                          action: () => hb
                          .Span(css: "ui-icon ui-icon-contact")
                          .Text(text: Displays.Support())))
                  .Li(action: () => hb
                      .A(
                          href: Parameters.General.HtmlPortalUrl,
                          target: "_blank",
                          action: () => hb
                          .Span(css: "ui-icon ui-icon-cart")
                          .Text(text: Displays.Portal())))
                  .Li(action: () => hb
                      .A(
                          href: Locations.Get("versions"),
                          action: () => hb
                          .Span(css: "ui-icon ui-icon-info")
                          .Text(text: Displays.Version())))));
 }
コード例 #3
0
 /// <summary>
 /// Fixed:
 /// </summary>
 public static Error.Types OnApiDeleting(UserModel userModel)
 {
     if (!Contract.Api())
     {
         return(Error.Types.InvalidRequest);
     }
     if (userModel.AccessStatus != Databases.AccessStatuses.Selected)
     {
         return(Error.Types.InvalidRequest);
     }
     return(Error.Types.None);
 }