選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

home.controller.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. angular.module('luticate')
  2. .controller('HomeController', ['$scope', 'luticateAuthCache', 'luticateDialogErrorHelper', 'luticateAuthUsers', '$state',
  3. function($scope, luticateAuthCache, luticateDialogErrorHelper, luticateAuthUsers, $state) {
  4. $scope.user = luticateAuthCache.getUser();
  5. $scope.userPassword = {
  6. old: "",
  7. value: "",
  8. confirm: ""
  9. };
  10. $scope.passwordValidation = {
  11. length: '$value.length >= 5 || $value.length == 0'
  12. };
  13. $scope.password2Validation = {
  14. same_passwords: 'userPassword.value==$value'
  15. };
  16. $scope.submit = function()
  17. {
  18. var promiseEditUser = {
  19. id: "promiseEditUser",
  20. loaderGroups: ["form"]
  21. };
  22. if (luticateAuthCache.hasEffectivePermission("LU_USER_EDIT_ME")) {
  23. luticateAuthUsers.editMe({
  24. email: $scope.user.Email,
  25. firstname: $scope.user.Firstname,
  26. lastname: $scope.user.Lastname
  27. }, promiseEditUser)
  28. .then(function(data)
  29. {
  30. $scope.load();
  31. $scope.mayEditPassword();
  32. }, luticateDialogErrorHelper.errorDialog);
  33. }
  34. else {
  35. $scope.mayEditPassword();
  36. }
  37. };
  38. $scope.mayEditPassword = function()
  39. {
  40. var promiseSetPassword = {
  41. id: "promiseSetPassword",
  42. loaderGroups: ["form"]
  43. };
  44. if ($scope.userPassword.value != ""
  45. && luticateAuthCache.hasEffectivePermission("LU_USER_SET_PASSWORD_ME")) {
  46. luticateAuthUsers.setPasswordMe({
  47. oldPassword: $scope.userPassword.old,
  48. password: $scope.userPassword.value
  49. }, promiseSetPassword)
  50. .then(function(data)
  51. {
  52. luticateAuthCache.removeUser();
  53. $state.go('login');
  54. }, luticateDialogErrorHelper.errorDialog);
  55. }
  56. };
  57. $scope.load = function()
  58. {
  59. var promiseLoadMe = {
  60. id: "promiseLoadMe",
  61. groups: ["form"]
  62. };
  63. luticateAuthUsers.getMe(promiseLoadMe)
  64. .then(function(user)
  65. {
  66. $scope.user = user;
  67. }, luticateDialogErrorHelper.errorDialog);
  68. };
  69. $scope.load();
  70. }]);