Browse Source

Passwords draft

master
Igor Zhukov 10 years ago
parent
commit
8047209ba5
  1. 30
      app/js/controllers.js
  2. 14
      app/js/services.js
  3. 47
      app/partials/desktop/password_update_modal.html
  4. 7
      app/partials/desktop/settings_modal.html

30
app/js/controllers.js

@ -2510,7 +2510,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2510,7 +2510,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
})
.controller('SettingsModalController', function ($rootScope, $scope, $timeout, $modal, AppUsersManager, AppChatsManager, AppPhotosManager, MtpApiManager, Storage, NotificationsManager, MtpApiFileManager, ApiUpdatesManager, ChangelogNotifyService, LayoutSwitchService, AppRuntimeManager, ErrorService, _) {
.controller('SettingsModalController', function ($rootScope, $scope, $timeout, $modal, AppUsersManager, AppChatsManager, AppPhotosManager, MtpApiManager, Storage, NotificationsManager, MtpApiFileManager, PasswordManager, ApiUpdatesManager, ChangelogNotifyService, LayoutSwitchService, AppRuntimeManager, ErrorService, _) {
$scope.profile = {};
$scope.photo = {};
@ -2533,6 +2533,30 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2533,6 +2533,30 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$watch('photo.file', onPhotoSelected);
$scope.password = {_: 'account.noPassword'};
updatePasswordState();
$scope.changePassword = function (options) {
options = options || {};
var scope = $rootScope.$new();
angular.extend(scope, options);
var modal = $modal.open({
scope: scope,
templateUrl: templateUrl('password_update_modal'),
controller: 'PasswordUpdateModalController',
windowClass: 'md_simple_modal_window mobile_modal'
});
modal.result['finally'](updatePasswordState);
};
function updatePasswordState (argument) {
PasswordManager.getPasswordState().then(function (result) {
$scope.password = result;
});
}
function onPhotoSelected (photo) {
if (!photo || !photo.type || photo.type.indexOf('image') !== 0) {
return;
@ -2858,6 +2882,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -2858,6 +2882,10 @@ angular.module('myApp.controllers', ['myApp.i18n'])
})
})
.controller('PasswordUpdateModalController', function ($scope, PasswordManager, MtpApiManager) {
})
.controller('ContactsModalController', function ($scope, $timeout, $modal, $modalInstance, MtpApiManager, AppUsersManager, ErrorService) {
$scope.contacts = [];

14
app/js/services.js

@ -4537,6 +4537,20 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -4537,6 +4537,20 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
})
.service('PasswordManager', function ($timeout, $rootScope, MtpApiManager) {
return {
getPasswordState: getPasswordState
};
function getPasswordState () {
return MtpApiManager.invokeApi('account.getPassword').then(function (result) {
return result;
});
}
})
.service('ErrorService', function ($rootScope, $modal, $window) {

47
app/partials/desktop/password_update_modal.html

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
<div class="md_simple_modal_wrap" my-modal-position>
<div class="md_simple_modal_body">
<form class="modal_simple_form" ng-submit="updatePassword()">
<h4 my-i18n="username_edit_modal_title"></h4>
<div ng-if="password._ != 'account.noPassword'" class="md-input-group" ng-class="{'md-input-error': checked.error}" my-labeled-input>
<label class="md-input-label" my-i18n="password_current_placeholder"></label>
<input class="md-input" my-focused type="text" ng-model="passwordSettings.current_password" name="current_password" />
</div>
<div class="md-input-group" ng-class="{'md-input-error': checked.error}" my-labeled-input>
<label class="md-input-label" my-i18n="password_new_placeholder"></label>
<input class="md-input" type="text" ng-model="passwordSettings.new_password" name="new_password" />
</div>
<div class="md-input-group" ng-class="{'md-input-error': checked.error}" my-labeled-input>
<label class="md-input-label" my-i18n="password_new_placeholder"></label>
<input class="md-input" type="text" ng-model="passwordSettings.confirm_password" name="confirm_password" />
</div>
<div class="md-input-group" ng-class="{'md-input-error': checked.error}" my-labeled-input>
<label class="md-input-label" my-i18n="password_new_placeholder"></label>
<input class="md-input" type="text" ng-model="passwordSettings.hint" name="hint" />
</div>
<div class="md-input-group" ng-class="{'md-input-error': checked.error}" my-labeled-input>
<label class="md-input-label" my-i18n="password_new_placeholder"></label>
<input class="md-input" type="text" ng-model="passwordSettings.email" name="email" />
</div>
<div class="md_simple_form_description" my-i18n="username_edit_description_md"></div>
</form>
</div>
<div class="md_simple_modal_footer">
<button class="btn btn-md" ng-click="$dismiss()" my-i18n="modal_cancel"></button>
<button class="btn btn-md btn-md-primary" ng-class="{disabled: passwordSettings.updating}" ng-click="updatePassword()" ng-bind="passwordSettings.updating ? 'username_edit_submit_active' : 'username_edit_submit' | i18n" ng-disabled="passwordSettings.updating"></button>
</div>
</div>

7
app/partials/desktop/settings_modal.html

@ -110,6 +110,13 @@ @@ -110,6 +110,13 @@
<div class="md_modal_section_param_name" my-i18n="settings_modal_language"></div>
</div>
<div class="md_modal_section_link_wrap">
<a ng-if="password._ == 'account.noPassword' && !password.email_unconfirmed_pattern" class="md_modal_section_link" ng-click="changePassword()">Set password</a>
<a ng-if="password._ == 'account.noPassword' && password.email_unconfirmed_pattern.length" class="md_modal_section_link" ng-click="changePassword({cancelEmail: true})">Cancel pending {{password.email_unconfirmed_pattern}}</a>
<a ng-if="password._ == 'account.password'" class="md_modal_section_link" ng-click="updatePassword({disable: true})">Turn off</a>
<a ng-if="password._ == 'account.password'" class="md_modal_section_link" ng-click="changePassword()">Change password</a>
</div>
<div class="md_modal_section_link_wrap">
<a class="md_modal_section_link" ng-click="terminateSessions()" my-i18n="settings_modal_terminate_sessions"></a>
</div>

Loading…
Cancel
Save