示例#1
0
 public virtual void PrintUserInfo(BoxUser user)
 {
     Reporter.WriteInformation("----Information about this user----");
     if (user.IsPlatformAccessOnly == true)
     {
         Reporter.WriteInformation("User is an App User");
     }
     if (user.Login.Contains("AutomationUser") && user.Login.Contains("@boxdevedition.com"))
     {
         Reporter.WriteInformation("User is a Service Account");
     }
     Reporter.WriteInformation($"User Id: {user.Id}");
     Reporter.WriteInformation($"User Status: {user.Status}");
     Reporter.WriteInformation($"User Type: {user.Type}");
     Reporter.WriteInformation($"User Name: {user.Name}");
     Reporter.WriteInformation($"User Login: {user.Login}");
     if (user.Enterprise != null)
     {
         Reporter.WriteInformation($"Enterprise this User Belongs to: {user.Enterprise.Name}");
         Reporter.WriteInformation($"Enterprise this User Belongs to: {user.Enterprise.Id}");
         Reporter.WriteInformation($"Enterprise this User Belongs to: {user.Enterprise.Type}");
     }
     Reporter.WriteInformation($"User Address: {user.Address}");
     Reporter.WriteInformation($"User Phone: {user.Phone}");
     Reporter.WriteInformation($"User Language: {user.Language}");
     Reporter.WriteInformation($"User Role: {user.Role}");
     Reporter.WriteInformation($"User Job Title: {user.JobTitle}");
     Reporter.WriteInformation($"User Max Upload Size: {user.MaxUploadSize}");
     Reporter.WriteInformation($"User Space Alloted: {user.SpaceAmount}");
     Reporter.WriteInformation($"User Space Used: {user.SpaceUsed}");
 }
示例#2
0
        public async Task DeleteEnterpriseUser_ValidReponse()
        {
            /*** Arrange ***/
            string      responseString = "";
            IBoxRequest boxRequest     = null;

            Handler.Setup(h => h.ExecuteAsync <BoxUser>(It.IsAny <IBoxRequest>()))
            .Returns(() => Task.FromResult <IBoxResponse <BoxUser> >(new BoxResponse <BoxUser>()
            {
                Status        = ResponseStatus.Success,
                ContentString = responseString
            }))
            .Callback <IBoxRequest>(r => boxRequest = r);

            BoxUser result = await _usersManager.DeleteEnterpriseUserAsync("userid", true, false);

            /*** Assert ***/

            // Request check
            Assert.IsNotNull(boxRequest);
            Assert.AreEqual(RequestMethod.Delete, boxRequest.Method);
            Assert.AreEqual(UserUri + "userid" + "?notify=True&force=False", boxRequest.AbsoluteUri.AbsoluteUri);

            // Response check
            Assert.IsNull(result);
        }
示例#3
0
        private async Task RunUpdate()
        {
            base.CheckForUserId(this._userId.Value, this._app);
            var boxClient   = base.ConfigureBoxClient(oneCallAsUserId: base._asUser.Value(), oneCallWithToken: base._oneUseToken.Value());
            var userRequest = base.CreateUserRequest(this._name.Value(), this._userId.Value, this._role.Value(), this._enterprise.HasValue(),
                                                     this._language.Value(), this._jobTitle.Value(), this._phoneNumber.Value(), this._address.Value(), this._spaceAmount.Value(),
                                                     this._status.Value(), this._syncDisable.HasValue(), this._syncEnable.HasValue(), this._isExemptFromDeviceLimits.HasValue(),
                                                     this._notExemptFromDeviceLimits.HasValue(), this._isExemptFromLoginVerificaton.HasValue(), this._notExemptFromLoginVerification.HasValue(),
                                                     this._isPasswordResetRequired.HasValue());

            BoxUser updatedUser = await boxClient.UsersManager.UpdateUserInformationAsync(userRequest);

            if (updatedUser.Id == this._userId.Value)
            {
                if (base._json.HasValue() || this._home.GetBoxHomeSettings().GetOutputJsonSetting())
                {
                    base.OutputJson(updatedUser);
                    return;
                }
                Reporter.WriteSuccess($"Updated user {this._userId.Value}");
                base.PrintUserInfo(updatedUser);
            }
            else
            {
                Reporter.WriteError($"Couldn't update user {this._userId.Value}");
            }
        }
        public async Task <IActionResult> Edit(string id, string role)
        {
            BoxUser user = await _boxUser.FindByIdAsync(id);

            if (String.IsNullOrEmpty(role))
            {
                role = "Terricola";
                return(View(user));
            }
            if (!String.IsNullOrEmpty(role))
            {
                await _boxUser.RemoveFromRoleAsync(user, "Sayan");

                await _boxUser.RemoveFromRoleAsync(user, "Terricola");

                await _boxUser.RemoveFromRoleAsync(user, "Namekiano");

                user.Tarifa = role;

                await _boxUser.AddToRoleAsync(user, role);

                await _boxUser.UpdateAsync(user);
            }

            return(RedirectToAction("index", "BoxUsers"));
        }
示例#5
0
        public async Task AddAsync(string box, string username, BoxRole?role = null)
        {
            var user = await GetUserAsyncOrFail(username);

            var boxEntry = await GetBoxAsyncOrFail(box);

            var boxUser = boxEntry.GetUser(username);

            if (boxUser != null)
            {
                throw new ArgumentException($"User '{username}' has been already added to box '{box}'.", nameof(username));
            }

            if (boxEntry.Users.Count() >= _featureSettings.UsersPerBoxLimit)
            {
                throw new InvalidOperationException($"Box: '{box}' already contains " +
                                                    $"{_featureSettings.UsersPerBoxLimit} users.");
            }

            boxUser = new BoxUser(user, role.GetValueOrDefault(BoxRole.BoxUser));
            if (user.IsActive)
            {
                boxUser.Activate();
            }

            boxUser.AddPermission(Permission.ReadEntryKeys);
            boxUser.AddPermission(Permission.ReadEntry);
            boxEntry.AddUser(boxUser);
            await _boxRepository.UpdateAsync(boxEntry);

            Logger.Info($"User '{username}' was added to the box '{boxEntry.Name}'.");
        }
示例#6
0
        public async Task GetUserInformationByUserId_ValidResponse_ValidUser()
        {
            /*** Arrange ***/
            string      responseString = "{\"type\": \"user\", \"id\": \"10543463\", \"name\": \"Arielle Frey\", \"login\": \"[email protected]\", \"created_at\": \"2011-01-07T12:37:09-08:00\", \"modified_at\": \"2014-05-30T10:39:47-07:00\", \"language\": \"en\", \"timezone\": \"America/Los_Angeles\", \"space_amount\": 10737418240,\"space_used\":558732,\"max_upload_size\": 5368709120,\"status\": \"active\",\"job_title\": \"\",\"phone\": \"\",\"address\": \"\",\"avatar_url\":\"https://blosserdemoaccount.app.box.com/api/avatar/large/10543465\"}";
            IBoxRequest boxRequest     = null;

            Handler.Setup(h => h.ExecuteAsync <BoxUser>(It.IsAny <IBoxRequest>()))
            .Returns(Task.FromResult <IBoxResponse <BoxUser> >(new BoxResponse <BoxUser>()
            {
                Status        = ResponseStatus.Success,
                ContentString = responseString
            }))
            .Callback <IBoxRequest>(r => boxRequest = r);

            /*** Act ***/
            BoxUser user = await _usersManager.GetUserInformationAsync("10543463");

            /*** Assert ***/
            // Request check
            Assert.IsNotNull(boxRequest);
            Assert.AreEqual(RequestMethod.Get, boxRequest.Method);
            Assert.AreEqual(UserUri + "10543463", boxRequest.AbsoluteUri.AbsoluteUri);
            // Response check
            Assert.AreEqual("10543463", user.Id);
            Assert.AreEqual("Arielle Frey", user.Name);
            Assert.AreEqual("*****@*****.**", user.Login);
            Assert.AreEqual("user", user.Type);
        }
示例#7
0
        // GET: BoxUserHorarios/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var boxUserHorario = await _BoxUserHorarioServices.GetBoxUserHorarioByIdAsync(id);

            if (boxUserHorario == null)
            {
                return(NotFound());
            }

            BoxUser user = await _boxUser.GetUserAsync(User);

            if (!await _boxUser.IsInRoleAsync(user, "Administrador"))
            {
                if (boxUserHorario.Horario.Hora <= DateTime.Now.AddMinutes(+30))
                {
                    return(View("Listillo"));
                }
            }


            return(View(boxUserHorario));
        }
        public async Task GetUserInformation_ExtraFields()
        {
            /*** Arrange ***/
            string responseString = @"{
                ""type"": ""user"",
                ""id"": ""12345"",
                ""name"": ""Example User"",
                ""timezone"": ""America/Los_Angeles"",
                ""is_external_collab_restricted"": true,
                ""my_tags"": [
                    ""important""
                ],
                ""hostname"": ""https://example.app.box.com/""
            }";

            Handler.Setup(h => h.ExecuteAsync <BoxUser>(It.IsAny <IBoxRequest>()))
            .Returns(Task.FromResult <IBoxResponse <BoxUser> >(new BoxResponse <BoxUser>()
            {
                Status        = ResponseStatus.Success,
                ContentString = responseString
            }));

            /*** Act ***/
            string[] fields = { "name", "timezone", "is_external_collab_restricted", "my_tags", "hostname" };
            BoxUser  user   = await _usersManager.GetCurrentUserInformationAsync(fields);

            /*** Assert ***/
            Assert.AreEqual("12345", user.Id);
            Assert.AreEqual("America/Los_Angeles", user.Timezone);
            Assert.IsTrue(user.IsExternalCollabRestricted.HasValue);
            Assert.IsTrue(user.IsExternalCollabRestricted.Value);
            Assert.AreEqual("important", user.Tags[0]);
            Assert.AreEqual("https://example.app.box.com/", user.Hostname);
        }
        public async Task GetUserInformation_WithField_ValidResponse_ValidUser()
        {
            /*** Arrange ***/
            IBoxRequest boxRequest     = null;
            string      responseString = "{\"type\": \"user\", \"id\": \"12345\", \"status\": \"active\"}";

            Handler.Setup(h => h.ExecuteAsync <BoxUser>(It.IsAny <IBoxRequest>()))
            .Returns(Task.FromResult <IBoxResponse <BoxUser> >(new BoxResponse <BoxUser>()
            {
                Status        = ResponseStatus.Success,
                ContentString = responseString
            }))
            .Callback <IBoxRequest>(r => boxRequest = r);

            /*** Act ***/
            string[] fields = { "status" };
            BoxUser  user   = await _usersManager.GetUserInformationAsync(userId : "12345", fields : fields);

            /*** Request Check ***/
            var parameter = boxRequest.Parameters.Values.FirstOrDefault();

            Assert.IsNotNull(boxRequest);
            Assert.AreEqual(RequestMethod.Get, boxRequest.Method);
            Assert.AreEqual("status", parameter);

            /*** Assert ***/
            Assert.AreEqual("12345", user.Id);
            Assert.AreEqual("user", user.Type);
            Assert.AreEqual("active", user.Status);
        }
        public async Task RolloutUserFromEnterprise_ValidResponse_ValidUser()
        {
            /*** Arrange ***/
            var         responseString = "{\"type\":\"user\",\"id\":\"181216415\",\"name\":\"sean\",\"login\":\"[email protected]\",\"created_at\":\"2012-05-03T21:39:11-07:00\",\"modified_at\":\"2012-12-06T18:17:16-08:00\",\"role\":\"admin\",\"language\":\"en\",\"space_amount\":5368709120,\"space_used\":1237179286,\"max_upload_size\":2147483648,\"tracking_codes\":[],\"can_see_managed_users\":true,\"is_sync_enabled\":true,\"status\":\"active\",\"job_title\":\"\",\"phone\":\"6509241374\",\"address\":\"\",\"avatar_url\":\"https://www.box.com/api/avatar/large/181216415\",\"is_exempt_from_device_limits\":false,\"is_exempt_from_login_verification\":false, \"notification_email\": { \"email\": \"[email protected]\", \"is_confirmed\": true}}";
            IBoxRequest boxRequest     = null;

            Handler.Setup(h => h.ExecuteAsync <BoxUser>(It.IsAny <IBoxRequest>()))
            .Returns(Task.FromResult <IBoxResponse <BoxUser> >(new BoxResponse <BoxUser>()
            {
                Status        = ResponseStatus.Success,
                ContentString = responseString
            }))
            .Callback <IBoxRequest>(r => boxRequest = r);

            /*** Act ***/
            var userRequest = new BoxUserRollOutRequest()
            {
                Id = "181216415",
            };
            BoxUser user = await _usersManager.UpdateUserInformationAsync(userRequest);

            /*** Assert ***/

            // Request check
            Assert.IsNotNull(boxRequest);
            Assert.AreEqual(RequestMethod.Put, boxRequest.Method);
            Assert.AreEqual(UserUri + "181216415", boxRequest.AbsoluteUri.AbsoluteUri);
            BoxUserRequest payload = JsonConvert.DeserializeObject <BoxUserRequest>(boxRequest.Payload);

            Assert.AreEqual(userRequest.Id, payload.Id);
            Assert.AreEqual(boxRequest.Payload, "{\"enterprise\":null,\"id\":\"181216415\"}");
        }
        public async Task UsersInformation_LiveSession_ValidResponse()
        {
            BoxUser user = await _client.UsersManager.GetCurrentUserInformationAsync();

            Assert.AreEqual("215917383", user.Id);
            Assert.AreEqual("Box Windows", user.Name);
            Assert.AreEqual("*****@*****.**", user.Login, true);
        }
        public async Task UsersInformation_LiveSession_ValidResponse()
        {
            BoxUser user = await _client.UsersManager.GetCurrentUserInformationAsync();

            Assert.AreEqual("189912110", user.Id);
            Assert.AreEqual("Brian", user.Name);
            Assert.AreEqual("*****@*****.**", user.Login);
        }
示例#13
0
        private void AccederSistema()
        {
            RN_Usuario obj = new RN_Usuario();
            DataTable  dt  = new DataTable();

            int veces = 0;

            if (ValidarTexBox() == false)
            {
                return;
            }

            string usu, pass;

            usu  = BoxUser.Text.Trim();
            pass = BoxPass.Text.Trim();

            if (obj.RN_Verificar_Acceso(usu, pass) == true)
            {
                // los datos son correctos
                MessageBox.Show("Bienvenido al Sistema", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information);


                Cls_Libreria.Usuario = usu;

                dt = obj.RN_Leer_Datos_Usuario(usu);
                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    Cls_Libreria.IdUsu     = Convert.ToString(dr["Id_Usu"]);
                    Cls_Libreria.Apellidos = dr["Nombre_Completo"].ToString();
                    Cls_Libreria.IdRol     = Convert.ToString(dr["Id_Rol"]);
                    Cls_Libreria.Rol       = dr["NomRol"].ToString();
                    Cls_Libreria.Foto      = dr["Avatar"].ToString();
                }

                this.Hide();
                Frm_Principal xmenuprincipal = new Frm_Principal();
                xmenuprincipal.Show();
                xmenuprincipal.Cargar_Datos_Usuario();
            }
            else
            {
                // si no son corractos
                MessageBox.Show("Usuario o contraseña no son validos", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                BoxUser.Text = "";
                BoxPass.Text = "";

                BoxUser.Focus();
                veces += 1;

                if (veces == 3)
                {
                    MessageBox.Show("El numero maximo de intentos fue superado", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Application.Exit();
                }
            }
        }
示例#14
0
        protected async Task UpdateUsersFromFile(string path,
                                                 bool save = false, string overrideSavePath = "", string overrideSaveFileFormat = "", bool json = false)
        {
            var boxClient = base.ConfigureBoxClient(oneCallAsUserId: this._asUser.Value(), oneCallWithToken: base._oneUseToken.Value());

            if (!string.IsNullOrEmpty(path))
            {
                path = GeneralUtilities.TranslatePath(path);
            }
            try
            {
                var            userRequests = base.ReadFile <BoxUserRequest, BoxUserUpdateRequestMap>(path);
                List <BoxUser> saveUpdated  = new List <BoxUser>();

                foreach (var userRequest in userRequests)
                {
                    BoxUser updatedUser = null;
                    try
                    {
                        updatedUser = await boxClient.UsersManager.UpdateUserInformationAsync(userRequest);
                    }
                    catch (Exception e)
                    {
                        Reporter.WriteError("Couldn't update user...");
                        Reporter.WriteError(e.Message);
                    }
                    if (updatedUser != null)
                    {
                        this.PrintUserInfo(updatedUser, json);
                        if (save || !string.IsNullOrEmpty(overrideSavePath) || base._settings.GetAutoSaveSetting())
                        {
                            saveUpdated.Add(updatedUser);
                        }
                    }
                }
                if (save || !string.IsNullOrEmpty(overrideSavePath) || base._settings.GetAutoSaveSetting())
                {
                    var fileFormat = base._settings.GetBoxReportsFileFormatSetting();
                    if (!string.IsNullOrEmpty(overrideSaveFileFormat))
                    {
                        fileFormat = overrideSaveFileFormat;
                    }
                    var savePath = base._settings.GetBoxReportsFolderPath();
                    if (!string.IsNullOrEmpty(overrideSavePath))
                    {
                        savePath = overrideSavePath;
                    }
                    var fileName = $"{base._names.CommandNames.Users}-{base._names.SubCommandNames.Update}-{DateTime.Now.ToString(GeneralUtilities.GetDateFormatString())}";
                    base.WriteListResultsToReport <BoxUser, BoxUserMap>(saveUpdated, fileName, savePath, fileFormat);
                }
            }
            catch (Exception e)
            {
                Reporter.WriteError(e.Message);
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (BoxUser.Text == "")
            {
                MessageBox.Show("username harus diisi!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                BoxUser.Focus();
                return;
            }
            if (BoxPass.Text == "")
            {
                MessageBox.Show("password harus diisi!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                BoxPass.Focus();
                return;
            }

            try
            {
                SqlConnection con = new SqlConnection();
                con.ConnectionString = "Data Source=ASUS-X555U-TDC;Initial Catalog=Rental-sound;User ID=sa;Password=1976";
                con.Open();
                string         query = ("select * from Register where username = '******' and password = '******'");
                SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                DataTable      dtbl  = new DataTable();
                sda.Fill(dtbl);

                string         queryadmin = ("select * from LoginAdmin where username = '******' and password = '******'");
                SqlDataAdapter admin      = new SqlDataAdapter(queryadmin, con);
                DataTable      dataadmin  = new DataTable();
                admin.Fill(dataadmin);

                if (dtbl.Rows.Count == 1)
                {
                    MessageBox.Show("Login Sukses");
                    MENU go = new MENU();
                    this.Hide();
                    go.ShowDialog();
                    this.Close();
                }
                else if (dataadmin.Rows.Count == 1)
                {
                    MessageBox.Show("Login Admin Sukses");
                    Menu_Admin go = new Menu_Admin();
                    this.Hide();
                    go.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Username atau password salah!");
                }
            }
            catch (SqlException f)
            {
                Console.WriteLine(f.Message);
            }
        }
        public async Task <IActionResult> OnPostConfirmationAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            // Get the information about the user from the external login provider
            var info = await _signInManager.GetExternalLoginInfoAsync();

            if (info == null)
            {
                ErrorMessage = "Error loading external login information during confirmation.";
                return(RedirectToPage("./Login", new { ReturnUrl = returnUrl }));
            }

            if (ModelState.IsValid)
            {
                var user = new BoxUser {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    result = await _userManager.AddLoginAsync(user, info);

                    if (result.Succeeded)
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider);

                        var userId = await _userManager.GetUserIdAsync(user);

                        var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                        code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                        var callbackUrl = Url.Page(
                            "/Account/ConfirmEmail",
                            pageHandler: null,
                            values: new { area = "Identity", userId = userId, code = code },
                            protocol: Request.Scheme);

                        await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                          $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            LoginProvider = info.LoginProvider;
            ReturnUrl     = returnUrl;
            return(Page());
        }
        public static async Task <BoxUser> CreateBoxUser(string email)
        {
            BoxUserRequest userRequest = new BoxUserRequest()
            {
                Name = email, IsPlatformAccessOnly = true
            };
            BoxUser appUser = await AdminClient().UsersManager.CreateEnterpriseUserAsync(userRequest);

            return(appUser);
        }
        public async Task <ActionResult> Setup()
        {
            string  email = this.GetCurrentUserEmail();
            BoxUser user  = await BoxHelper.CreateBoxUser(email);

            BoxClient userClient = BoxHelper.UserClient(user.Id);
            await BoxHelper.Setup(userClient);

            return(RedirectToAction("index", "home"));
        }
示例#19
0
        public static async Task GetInfo()
        {
            var config  = new BoxConfig(BoxLogin.sBoxClientId, BoxLogin.sBoxClientSecret, new Uri("http://localhost"));
            var session = new OAuthSession(BoxLogin.token, "NOT_NEEDED", 3600, "bearer");

            client = new BoxClient(config, session);
            BoxUser currentUser = await client.UsersManager.GetCurrentUserInformationAsync();

            UserName = currentUser.Name;
        }
示例#20
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new BoxUser
                {
                    UserName  = Input.Email,
                    Email     = Input.Email,
                    FirstName = Input.Firstname,
                    LastName  = Input.LastName,
                    Tarifa    = Input.Tarifa
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(user, user.Tarifa);// Le damos un Rol == Tarifa que elige, y así a la hora de filtrar con Authorized es más fácil.


                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
示例#21
0
        private async Task RunDelete()
        {
            var boxClient = base.ConfigureBoxClient(oneCallAsUserId: base._asUser.Value(), oneCallWithToken: base._oneUseToken.Value());
            if (this._path.HasValue())
            {
                var path = GeneralUtilities.TranslatePath(this._path.Value());
                var ids = base.ReadFileForIds(path);
                foreach (var id in ids)
                {
                    BoxUser result;
                    try
                    {
                        result = await boxClient.UsersManager.DeleteEnterpriseUserAsync(id, notify: false, force: true);
                        Reporter.WriteSuccess($"Deleted user {id}");
                    }
                    catch (Exception e)
                    {
                        Reporter.WriteError($"Error deleting user {id}.");
                        Reporter.WriteError(e.Message);
                    }
                }
                Reporter.WriteInformation("Finished deleting users...");
                return;
            }
            base.CheckForUserId(this._userId.Value, this._app);
            var userDeleted = new BoxUser();
            if (this._dontPrompt.HasValue())
            {
                userDeleted = await boxClient.UsersManager.DeleteEnterpriseUserAsync(this._userId.Value, this._notify.HasValue(), this._force.HasValue());
            }
            else
            {
                Reporter.WriteWarningNoNewLine("Are you sure you want to delete this user? y/N ");
                var yNKey = "n";
                yNKey = Console.ReadLine().ToLower();
                if (yNKey != "y")
                {
                    Reporter.WriteInformation("Aborted user deletion.");
                    return;
                }
                else
                {
                    userDeleted = await boxClient.UsersManager.DeleteEnterpriseUserAsync(this._userId.Value, this._notify.HasValue(), this._force.HasValue());
                }
            }

            if (userDeleted == null)
            {
                Reporter.WriteSuccess($"Deleted user {this._userId.Value}");
            }
            else
            {
                Reporter.WriteError($"Couldn't delete user {this._userId.Value}");
            }
        }
示例#22
0
        public async Task <IActionResult> MisClases()
        {
            BoxUser user = await _boxUser.GetUserAsync(User);

            List <BoxUserHorario> userHorario = await _BoxUserHorarioServices.GetBoxUserHorarioAsync();

            userHorario = userHorario.Where(x => x.BoxUserId == user.Id).OrderBy(x => x.Horario.Dia).ToList();


            return(View(userHorario));
        }
示例#23
0
 public virtual void PrintUserInfo(BoxUser user, bool json = false)
 {
     if (json)
     {
         base.OutputJson(user);
         return;
     }
     else
     {
         this.PrintUserInfo(user);
     }
 }
示例#24
0
        private async Task LoadAsync(BoxUser user)
        {
            var email = await _userManager.GetEmailAsync(user);

            Email = email;

            Input = new InputModel
            {
                NewEmail = email,
            };

            IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user);
        }
示例#25
0
        public async Task <string> Execute(IBoxClient client)
        {
            var userRequest = new BoxUserRequest
            {
                Name = _name,
                IsPlatformAccessOnly = true,
                ExternalAppUserId    = _externalAppUserId
            };

            BoxUser = await client.UsersManager.CreateEnterpriseUserAsync(userRequest);

            _id = BoxUser.Id;

            return(BoxUser.Id);
        }
示例#26
0
        private async Task LoadAsync(BoxUser user)
        {
            var userName = await _userManager.GetUserNameAsync(user);

            var phoneNumber = await _userManager.GetPhoneNumberAsync(user);

            Username = userName;

            Input = new InputModel
            {
                PhoneNumber = phoneNumber,
                FirstName   = user.FirstName,
                LastName    = user.LastName,
            };
        }
示例#27
0
        public async Task <IActionResult> ValidarClase(int Id)
        {
            BoxUser user = await _boxUser.GetUserAsync(User);

            BoxUserHorario boxUserHorario = new BoxUserHorario()
            {
                BoxUserId = user.Id,
                HorarioId = Id
            };

            List <BoxUserHorario> listaBoxUserHorario = await _BoxUserHorarioServices.GetBoxUserHorarioAsync();

            listaBoxUserHorario = listaBoxUserHorario.Where(x => x.BoxUserId == user.Id).ToList();

            foreach (BoxUserHorario item in listaBoxUserHorario)
            {
                if ((item.HorarioId == Id))
                {
                    return(View("ClaseRepetida"));
                }
            }

            if (await _boxUser.IsInRoleAsync(user, "Terricola") && listaBoxUserHorario.Count >= 5)
            {
                return(View("LimiteClasesExcedido"));
            }
            if (await _boxUser.IsInRoleAsync(user, "Namekiano") && listaBoxUserHorario.Count >= 10)
            {
                return(View("LimiteClasesExcedido"));
            }
            if (await _boxUser.IsInRoleAsync(user, "Sayan") && listaBoxUserHorario.Count >= 15)
            {
                return(View("LimiteClasesExcedido"));
            }

            List <BoxUserHorario> listaBoxUserHorario2 = await _BoxUserHorarioServices.GetBoxUserHorarioAsync();

            listaBoxUserHorario2 = listaBoxUserHorario2.Where(x => x.HorarioId == Id).ToList();

            if (listaBoxUserHorario2.Count >= 3)
            {
                return(View("LimiteClase"));
            }

            await _BoxUserHorarioServices.CreateBoxUserHorarioAsync(boxUserHorario);

            return(RedirectToAction("Index", "Clases"));
        }
示例#28
0
        private static async Task <BoxFolder> CreateFolderAsync(BoxClient auClient, BoxUser appUser, int num,
                                                                TimeLimiter throttle)
        {
            var folderParams = new BoxFolderRequest()
            {
                Name   = "TestFolder" + num,
                Parent = new BoxRequestEntity()
                {
                    Id = "0"
                }
            };
            await throttle;
            var   folder = await auClient.FoldersManager.CreateAsync(folderParams);

            return(folder);
        }
示例#29
0
        public async Task ChangeUsersLogin_ValidReponse()
        {
            /*** Arrange ***/
            IBoxRequest boxRequest = null;

            Handler.Setup(h => h.ExecuteAsync <BoxUser>(It.IsAny <IBoxRequest>()))
            .Returns(() => Task.FromResult <IBoxResponse <BoxUser> >(new BoxResponse <BoxUser>()
            {
                Status        = ResponseStatus.Success,
                ContentString = "{\"type\":\"user\",\"id\":\"18180156\",\"name\":\"Dan Glover\",\"login\":\"[email protected]\",\"created_at\":\"2012-09-13T10:19:51-07:00\",\"modified_at\":\"2012-09-21T10:24:51-07:00\",\"role\":\"user\",\"language\":\"en\",\"space_amount\":5368709120,\"space_used\":0,\"max_upload_size\":1073741824,\"tracking_codes\":[],\"can_see_managed_users\":false,\"is_sync_enabled\":false,\"status\":\"active\",\"job_title\":\"\",\"phone\":\"\",\"address\":\"\",\"avatar_url\":\"\"}"
            }))
            .Callback <IBoxRequest>(r => boxRequest = r);

            /*** Act ***/
            BoxUser result = await _usersManager.ChangeUsersLoginAsync("userId", "userLogin");

            /*** Assert ***/

            // Request check
            Assert.IsNotNull(boxRequest);
            Assert.AreEqual(RequestMethod.Put, boxRequest.Method);
            Assert.AreEqual(UserUri + "userId", boxRequest.AbsoluteUri.AbsoluteUri);
            Assert.IsNotNull(boxRequest.Payload);
            Assert.IsTrue(AreJsonStringsEqual("{\"login\":\"userLogin\"}", boxRequest.Payload));

            // Response check
            Assert.AreEqual("user", result.Type);
            Assert.AreEqual("18180156", result.Id);
            Assert.AreEqual("Dan Glover", result.Name);
            Assert.AreEqual("*****@*****.**", result.Login);
            Assert.AreEqual(DateTime.Parse("2012-09-13T10:19:51-07:00"), result.CreatedAt);
            Assert.AreEqual("user", result.Role);
            Assert.AreEqual("en", result.Language);
            Assert.AreEqual(5368709120, result.SpaceAmount);
            Assert.AreEqual(0, result.SpaceUsed);
            Assert.AreEqual(1073741824, result.MaxUploadSize);
            Assert.AreEqual(0, result.TrackingCodes.Count);
            Assert.AreEqual(false, result.CanSeeManagedUsers);
            Assert.AreEqual(false, result.IsSyncEnabled);
            Assert.AreEqual("active", result.Status);
            Assert.IsTrue(string.IsNullOrEmpty(result.JobTitle));
            Assert.IsTrue(string.IsNullOrEmpty(result.Phone));
            Assert.IsTrue(string.IsNullOrEmpty(result.Address));
            Assert.IsTrue(string.IsNullOrEmpty(result.AvatarUrl));
        }
示例#30
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var boxUserHorario = await _BoxUserHorarioServices.GetBoxUserHorarioByIdAsync(id);

            await _BoxUserHorarioServices.DeleteBoxUserHorarioAsync(boxUserHorario);


            BoxUser user = await _boxUser.GetUserAsync(User);

            if (await _boxUser.IsInRoleAsync(user, "Administrador"))
            {
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(RedirectToAction(nameof(MisClases)));
            }
        }