- Timestamp:
- 05/20/16 13:01:12 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/HomeController.cs
r13805 r13854 31 31 ViewBag.Title = "Login"; 32 32 var user = HttpContext.Session.GetString("UserId"); 33 if (user != null && user != "")33 if (user != null && user != "") 34 34 { 35 35 Guid t = Guid.Parse(user); … … 61 61 62 62 client = hiveServiceLocator.getHiveServiceClient(); 63 try { 63 try 64 { 64 65 var test = client.GetJobs();//Throws messageSecurityException if login failss 65 66 ViewBag.Title = "Login succesful"; 66 67 weblog.newLogin(model, hiveServiceLocator); 67 68 HttpContext.Session.SetString("UserId", model.userId.ToString()); 68 return RedirectToAction("Index", "Job");69 return RedirectToAction("Index", "Job"); 69 70 } 70 catch (MessageSecurityException e)71 catch (MessageSecurityException e) 71 72 { 72 73 ViewBag.Title = "Login"; … … 75 76 return View("Index", model); 76 77 } 77 catch (SecurityAccessDeniedException e)78 catch (SecurityAccessDeniedException e) 78 79 { 79 ViewBag.Title = "Access denied - Login"; 80 model = new LoginViewModel(); 81 model.errorMessage = "Access denied, you have no permission to use this application." + 82 " Contact a HeuristicLab Hive admin to gain access."; 83 return View("Index", model); 80 var q = new QueryWebClient(model, password); 81 if (q.CheckLogin()) 82 { 83 ViewBag.Title = "Login succesful"; 84 weblog.newLoginOKBOnly(model,q); 85 HttpContext.Session.SetString("UserId", model.userId.ToString()); 86 return RedirectToAction("Index", "Query"); 87 } 88 else 89 { 90 ViewBag.Title = "Access denied - Login"; 91 model = new LoginViewModel(); 92 model.errorMessage = "Access denied, you have no permission to use this application." + 93 " Contact a HeuristicLab Hive admin to gain access."; 94 return View("Index", model); 95 } 96 84 97 } 85 98 … … 99 112 public IActionResult Logout() 100 113 { 101 return RedirectToAction("Index", "Home");114 return RedirectToAction("Index", "Home"); 102 115 } 103 116 #endregion -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/JobController.cs
r13847 r13854 40 40 { 41 41 weblog = WebLoginService.Instance; 42 42 43 43 _environment = env; 44 44 } … … 50 50 { 51 51 var u = HttpContext.Session.GetString("UserId"); 52 52 53 53 if (u == null || u == "" || Guid.Parse(u) == Guid.Empty) 54 54 { … … 60 60 vm = new JobViewModel(weblog.getCurrentUser(userId)); 61 61 upper = new UploadedJobViewModel(weblog.getCurrentUser(userId)); 62 63 serviceLocator = weblog.getServiceLocator(userId); 64 serviceClient = serviceLocator.getHiveServiceClient(); 65 clientWeb = weblog.getClientWeb(userId); 66 67 return serviceLocator.CheckLogin(); 68 } 62 try 63 { 64 serviceLocator = weblog.getServiceLocator(userId); 65 serviceClient = serviceLocator.getHiveServiceClient(); 66 clientWeb = weblog.getClientWeb(userId); 67 if (serviceLocator != null && serviceClient != null && clientWeb != null) 68 return serviceLocator.CheckLogin(); 69 } 70 catch (NullReferenceException) 71 { 72 return false; 73 } 74 } 75 return false; 69 76 } 70 77 … … 200 207 fillUploadsPaths(upper, -1); 201 208 var ind = upper.DisplayDatePaths.IndexOf(olddir); 202 try { 203 204 205 var start = Path.Combine(_environment.WebRootPath, "uploads", serviceClient.ClientCredentials.UserName.UserName, dirname); 209 try 210 { 211 212 213 var start = Path.Combine(_environment.WebRootPath, "uploads", serviceClient.ClientCredentials.UserName.UserName, dirname); 206 214 if (Directory.Exists(start)) 207 215 { 208 216 var files = Directory.GetFiles(upper.FullDatePaths[ind]); 209 foreach(var f in files) { 217 foreach (var f in files) 218 { 210 219 var target = start + "\\" + f.Split('\\').Last(); 211 220 if (System.IO.File.Exists(target)) 212 221 System.IO.File.Delete(target); 213 222 System.IO.File.Move(f, target); 214 223 } 215 224 } 216 225 else … … 218 227 Directory.Move(upper.FullDatePaths[ind], start); 219 228 } 220 221 upper.clear(); 222 fillUploadsPaths(upper, -1); 223 ind = upper.DisplayDatePaths.IndexOf(dirname); 224 upper.clear(); 225 return RedirectToAction("UploadDir",new { index=ind}); 226 }catch(IOException e) 229 230 upper.clear(); 231 fillUploadsPaths(upper, -1); 232 ind = upper.DisplayDatePaths.IndexOf(dirname); 233 upper.clear(); 234 return RedirectToAction("UploadDir", new { index = ind }); 235 } 236 catch (IOException e) 227 237 { 228 238 upper.clear(); 229 239 fillUploadsPaths(upper, ind); 230 240 upper.message = "Error in new directory name. Try again and don't use any special signs"; 231 ViewBag.Title = "Error renaming - " + upper.DisplayDatePaths[ind] + " - Uploads";241 ViewBag.Title = "Error renaming - " + upper.DisplayDatePaths[ind] + " - Uploads"; 232 242 if (weblog.getFileOpener(userId).Job != null) 233 243 ViewBag.active = true; … … 247 257 private void fillUploadsPaths(UploadedJobViewModel vm, int index) 248 258 { 249 259 250 260 var tempdex = index; //Fix when maps gets deleted 251 261 var start = Path.Combine(_environment.WebRootPath, "uploads", serviceClient.ClientCredentials.UserName.UserName); … … 254 264 Directory.GetDirectories(start); 255 265 } 256 catch (DirectoryNotFoundException e)266 catch (DirectoryNotFoundException e) 257 267 { 258 268 Directory.CreateDirectory(start); … … 407 417 fillUploadsPaths(upper, -1); 408 418 var ind = upper.DisplayDatePaths.IndexOf(dname); 409 return RedirectToAction("UploadDir", new { index = ind });419 return RedirectToAction("UploadDir", new { index = ind }); 410 420 } 411 421 else -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/ResourceController.cs
r13847 r13854 47 47 else 48 48 { 49 try { 49 50 userId = Guid.Parse(u); 50 51 serviceLocator = weblog.getServiceLocator(userId); … … 56 57 else 57 58 return false; 59 } 60 catch (NullReferenceException) 61 { 62 return false; 63 } 58 64 } 59 65 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Controllers/UserController.cs
r13848 r13854 36 36 /// </summary> 37 37 /// <returns></returns> 38 38 39 39 private bool init() 40 40 { … … 46 46 else 47 47 { 48 userId = Guid.Parse(u); 49 serviceLocator = weblog.getServiceLocator(userId); 50 accessClient = weblog.getAccessAdminClient(userId); 51 vm = new UserViewModel(accessClient, weblog.getCurrentUser(userId)); 52 if (weblog.getCurrentUser(userId).HasUserAdminAccess()) 53 return serviceLocator.CheckLogin(); 54 else 48 try 49 { 50 userId = Guid.Parse(u); 51 serviceLocator = weblog.getServiceLocator(userId); 52 accessClient = weblog.getAccessAdminClient(userId); 53 vm = new UserViewModel(accessClient, weblog.getCurrentUser(userId)); 54 if (weblog.getCurrentUser(userId).HasUserAdminAccess()) 55 return serviceLocator.CheckLogin(); 56 else 57 return false; 58 } 59 catch (NullReferenceException) 60 { 55 61 return false; 56 62 } 57 63 } 58 64 } … … 67 73 { 68 74 ViewBag.Title = "Users"; 69 vm.refreshAll() 75 vm.refreshAll(); 70 76 //Refreshall for users, groups and roles 71 77 ViewBag.SessionId = HttpContext.Session.GetString("UserId"); … … 77 83 } 78 84 } 79 85 80 86 public IActionResult SelectUser(string id) 81 87 { … … 158 164 } 159 165 accessClient.RefreshUserGroups(); 160 foreach (var g in groupstoadd)166 foreach (var g in groupstoadd) 161 167 {//loop to subscribe to groups 162 168 var gid = Guid.Parse(g); … … 206 212 207 213 vm.refreshAll(); 208 209 214 215 var us = vm.getUserById(curr); 210 216 us.IsApproved = true; 211 217 accessClient.updateUser(us); … … 291 297 var user = vm.getUserById(mid); 292 298 var gr = vm.getGroupById(gid); 293 299 294 300 accessClient.deleteMember(user, gr); 295 return RedirectToAction("SelectUser", new { id = id });301 return RedirectToAction("SelectUser", new { id = id }); 296 302 } 297 303 else
Note: See TracChangeset
for help on using the changeset viewer.