Exemplo n.º 1
0
        public IActionResult OnGet(int id, string redirect)
        {
            // Authorization
            AuthorizationResult authorizationResult;

            if (!Authorization.CheckAuthorization(HttpContext, MySQL, HttpContext.Response, out authorizationResult))
            {
                return(StatusCode(authorizationResult.StatusCode));
            }
            LoginUser = authorizationResult.Account;
            if (LoginUser.ROLE != "admin")
            {
                return(Redirect("/Betausers"));
            }

            if (!String.IsNullOrEmpty(Convert.ToString(id)))
            {
                BetaUser DeleteBetauser = MySQL.Get <BetaUser>(id);
                MySQL.Delete(DeleteBetauser);
            }
            if (String.IsNullOrEmpty(redirect))
            {
                return(Redirect("/Betausers"));
            }
            else
            {
                return(Redirect(redirect));
            }
        }
        private async Task <IEnumerable <String> > ImportUserAsync(APIOptions apiOptions, IGenericRepository <kCura.Relativity.Client.DTOs.User> userRepository)
        {
            List <String> violations = new List <string>();

            kCura.Relativity.Client.DTOs.User user = null;
            try
            {
                apiOptions.WorkspaceID = -1;
                user = new kCura.Relativity.Client.DTOs.User()
                {
                    FirstName                     = (String)await FirstName.GetDataValueAsync(),
                    LastName                      = (String)await LastName.GetDataValueAsync(),
                    EmailAddress                  = (String)await EmailAddress.GetDataValueAsync(),
                    Groups                        = _groupList,
                    Type                          = _userType,
                    Client                        = _client,
                    RelativityAccess              = ((Boolean?)await RelativityAccess.GetDataValueAsync()).GetValueOrDefault(),
                    DocumentSkip                  = _documentSkip,
                    BetaUser                      = ((Boolean?)await BetaUser.GetDataValueAsync()).GetValueOrDefault(),
                    ChangeSettings                = ((Boolean?)await ChangeSettings.GetDataValueAsync()).GetValueOrDefault(),
                    KeyboardShortcuts             = ((Boolean?)await KeyboardShortcuts.GetDataValueAsync()).GetValueOrDefault(),
                    ItemListPageLength            = ((Int32?)await ItemListPageLength.GetDataValueAsync()).GetValueOrDefault(),
                    DefaultSelectedFileType       = _defaultSelectedFileType,
                    SkipDefaultPreference         = _skipDefaultPreference,
                    EnforceViewerCompatibility    = ((Boolean?)await EnforceViewerCompatibility.GetDataValueAsync()).GetValueOrDefault(),
                    AdvancedSearchPublicByDefault = ((Boolean?)await AdvancedSearchPublicByDefault.GetDataValueAsync()).GetValueOrDefault(),
                    NativeViewerCacheAhead        = ((Boolean?)await NativeViewerCacheAhead.GetDataValueAsync()).GetValueOrDefault(),
                    CanChangeDocumentViewer       = ((Boolean?)await ChangeDocumentViewer.GetDataValueAsync()).GetValueOrDefault(),
                    DocumentViewer                = _documentViewer,
                    TrustedIPs                    = String.Empty,
                    ChangePassword                = ((Boolean?)await CanChangePassword.GetDataValueAsync()).GetValueOrDefault(),
                    MaximumPasswordAge            = ((Int32?)await MaximumPasswordAgeInDays.GetDataValueAsync()).GetValueOrDefault(),
                    DataFocus                     = 1, // This field is no longer utilized in Relativity, however it's hardcoded because it is required
                    ChangePasswordNextLogin       = ((Boolean?)await UserMustChangePasswordOnNextLogin.GetDataValueAsync()).GetValueOrDefault()
                };

                ArtifactId = userRepository.CreateSingle(user);
            }
            catch (Exception ex)
            {
                String msg = null;
                if (ex.ToString().Contains("The entered E-Mail Address is already associated with a user") && user != null && !String.IsNullOrWhiteSpace(user.EmailAddress))
                {
                    msg = String.Format(Constant.ErrorMessages.UserAlreadyExists, user.EmailAddress);
                }
                else
                {
                    msg = ex.ToString();
                }
                violations.Add(msg);
            }
            return(violations);
        }
Exemplo n.º 3
0
        public IActionResult OnPostAsync()
        {
            BetaUser NewBetaUser = new BetaUser();

            NewBetaUser.USERNAME = Username;
            MySQL.Insert(NewBetaUser);

            if (String.IsNullOrEmpty(redirect))
            {
                return(Redirect("/Betausers"));
            }
            return(Redirect(redirect));
        }