Browse Source

Supported two-step login on mobile

Fixed sha256 in crypto.js
master
Igor Zhukov 10 years ago
parent
commit
939ab4786c
  1. 6
      app/js/lib/bin_utils.js
  2. 27
      app/partials/mobile/login.html
  3. 49
      app/partials/mobile/password_recovery_modal.html

6
app/js/lib/bin_utils.js

@ -318,9 +318,9 @@ function sha1BytesSync (bytes) {
} }
function sha256HashSync (bytes) { function sha256HashSync (bytes) {
console.log(dT(), 'SHA-2 hash start', bytes.byteLength || bytes.length); // console.log(dT(), 'SHA-2 hash start', bytes.byteLength || bytes.length);
var hashWords = CryptoJS.SHA256(bytes); var hashWords = CryptoJS.SHA256(bytesToWords(bytes));
console.log(dT(), 'SHA-2 hash finish'); // console.log(dT(), 'SHA-2 hash finish');
var hashBytes = bytesFromWords(hashWords); var hashBytes = bytesFromWords(hashWords);

27
app/partials/mobile/login.html

@ -6,7 +6,7 @@
<ul class="nav navbar-nav navbar-quick-nav"> <ul class="nav navbar-nav navbar-quick-nav">
<li class="navbar-quick-right login_head_submit_wrap"> <li class="navbar-quick-right login_head_submit_wrap">
<a class="disabled" disabled="disabled" ng-if="progress.enabled" class="login_head_submit_progress"> <a class="disabled" disabled="disabled" ng-if="progress.enabled" class="login_head_submit_progress">
<my-i18n ng-if="!credentials.phone_code_hash" msgid="login_generating_key"></my-i18n><my-i18n ng-if="credentials.phone_code_hash &amp;&amp; !credentials.phone_code_valid" msgid="login_checking_code"></my-i18n><my-i18n ng-if="credentials.phone_code_valid &amp;&amp; credentials.phone_unoccupied" msgid="login_signing_up"></my-i18n><span my-loading-dots></span> <my-i18n ng-if="!credentials.phone_code_hash" msgid="login_generating_key"></my-i18n><my-i18n ng-if="credentials.phone_code_hash &amp;&amp; !credentials.phone_code_valid" msgid="login_checking_code"></my-i18n><my-i18n ng-if="credentials.phone_code_valid &amp;&amp; credentials.phone_unoccupied" msgid="login_signing_up"></my-i18n><my-i18n ng-if="credentials.phone_code_valid &amp;&amp; credentials.password_needed" msgid="login_checking_password"></my-i18n><span my-loading-dots></span>
</a> </a>
<a ng-if="!progress.enabled &amp;&amp; !credentials.phone_code_hash" ng-click="sendCode()"> <a ng-if="!progress.enabled &amp;&amp; !credentials.phone_code_hash" ng-click="sendCode()">
<my-i18n msgid="modal_next"></my-i18n><i class="icon icon-next-submit"></i> <my-i18n msgid="modal_next"></my-i18n><i class="icon icon-next-submit"></i>
@ -17,6 +17,9 @@
<a ng-if="!progress.enabled &amp;&amp; credentials.phone_code_valid &amp;&amp; credentials.phone_unoccupied" ng-click="logIn(true)"> <a ng-if="!progress.enabled &amp;&amp; credentials.phone_code_valid &amp;&amp; credentials.phone_unoccupied" ng-click="logIn(true)">
<my-i18n msgid="modal_next"></my-i18n><i class="icon icon-next-submit"></i> <my-i18n msgid="modal_next"></my-i18n><i class="icon icon-next-submit"></i>
</a> </a>
<a ng-if="!progress.enabled &amp;&amp; credentials.phone_code_valid &amp;&amp; credentials.password_needed" ng-click="checkPassword()">
<my-i18n msgid="modal_next"></my-i18n><i class="icon icon-next-submit"></i>
</a>
</li> </li>
<li> <li>
<a class="navbar-brand tg_logo_wrap" href="https://telegram.org" target="_blank"><i class="icon icon-tg-logo"></i><i class="icon icon-tg-title"></i></a> <a class="navbar-brand tg_logo_wrap" href="https://telegram.org" target="_blank"><i class="icon icon-tg-logo"></i><i class="icon icon-tg-title"></i></a>
@ -108,6 +111,28 @@
</form> </form>
<form name="myPasswordForm" ng-if="credentials.phone_code_valid &amp;&amp; credentials.password_needed" ng-submit="checkPassword()">
<h3 class="login_form_head" my-i18n="login_password_title"></h3>
<p class="login_form_lead" my-i18n="login_password_label"></p>
<div class="md-input-group" ng-class="{'md-input-error': error.field == 'password'}" my-labeled-input ng-switch="error.field == 'password'">
<label ng-switch-when="true" class="md-input-label" my-i18n="login_incorrect_password"></label>
<label ng-switch-default class="md-input-label" my-i18n="login_password"></label>
<input autocomplete="off" class="md-input" my-focused name="password" type="password" ng-model="credentials.password" my-submit-on-enter required />
</div>
<p ng-if="password.hint.length > 0" class="login_form_hint" ng-bind="password.hint"></p>
<div class="login_forgot_button">
<button class="btn btn-md" ng-click="forgotPassword($event)" my-i18n="login_password_forgot_link"></button>
</div>
<div ng-if="canReset" class="login_reset_button">
<button class="btn btn-md btn-md-danger" ng-click="resetAccount($event)" my-i18n="login_account_reset"></button>
</div>
</form>
</div> </div>
<div ng-switch="about.shown"> <div ng-switch="about.shown">

49
app/partials/mobile/password_recovery_modal.html

@ -0,0 +1,49 @@
<div class="username_edit_modal_wrap">
<div class="tg_page_head tg_modal_head">
<div class="navbar navbar-static-top navbar-inverse">
<div class="container">
<div class="navbar-header">
<ul class="nav navbar-nav navbar-quick-nav">
<li class="navbar-quick-right">
<a ng-class="{disabled: recovery.updating}" ng-click="checkCode()" ng-bind="recovery.updating ? 'password_recover_active' : 'password_recover_submit' | i18n" ng-disabled="recovery.updating"></a>
</li>
<li>
<a ng-click="$dismiss()" class="navbar-quick-media-back">
<i class="icon icon-back"></i>
<div class="navbar-quick-back-title">
<h4 my-i18n="login_recovery_title"></h4>
</div>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="modal-body">
<form class="modal_simple_form" ng-submit="checkCode()">
<div class="md_simple_form_description" my-i18n="login_recovery_description_md">
<my-i18n-param name="email">
<strong ng-bind="recovery.email_pattern"></strong>
</my-i18n-param>
</div>
<div class="md-input-group" ng-class="{'md-input-error': recovery.error_field == 'code'}" my-labeled-input ng-switch="recovery.error_field == 'code'">
<label ng-switch-when="true" class="md-input-label" my-i18n="login_code_incorrect"></label>
<label ng-switch-default class="md-input-label" my-i18n="login_code_placeholder"></label>
<input class="md-input" my-focused type="text" ng-model="recovery.code" name="code" my-focused />
</div>
</form>
</div>
</div>
Loading…
Cancel
Save