unit TestApp.Shared;

interface

uses
  Sphinx.Consts;

type

{$SCOPEDENUMS ON}
  TUserScope = (
    None,
    ReadOnly,
    User,
    AdminUser,
    Administrator,
    SuperUser,
    Customer,
    ManagerApp
  );

const
  USER_SCOPES: array [TUserScope] of string = (
    'None',
    'ReadOnly',
    'User',
    'AdminUser',
    'Administrator',
    'SuperUser',
    'Customer',
    'ManagerApp'
  );

  CLAIM_SCOPE = 'scope';

  SCOPE_NONE = 'NONE';
  SCOPE_USER = 'USER';
  SCOPE_ADMIN = 'Administrator';

  App_Name = 'SphinxLogoutTest';
  App_Manager_Scope = App_Name + '_MANAGER';
  App_Web_App_Id = App_Name + '_WEB';

function IsValidScope(const Value: string): Boolean;
function StrToUserScope(const Value: string): TUserScope;

implementation

uses
  Rtti;

function IsValidScope(const Value: string): Boolean;
var
  lScope: TUserScope;
begin
  Result := False;
  for lScope := Low(TUserScope) to High(TUserScope) do
  begin
    if USER_SCOPES[lScope] = Value then
      Exit(True);
  end;
end;

function StrToUserScope(const Value: string): TUserScope;
begin
  Result := TRttiEnumerationType.GetValue<TUserScope>(Value);
end;

{$SCOPEDENUMS OFF}

end.
