Skip to content

Commit

Permalink
+ support for Two-Factor password auth added
Browse files Browse the repository at this point in the history
  • Loading branch information
zevlg committed Apr 27, 2018
1 parent 6450a8d commit e0cc4f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion telega-root.el
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ If RAW is given then do not modify status for animation."
"Something changed in CHAT, button needs to be updated.
If there is no button for the CHAT, new button is created.
If INHIBIT-FILTERS-REDISPLAY specified then do not redisplay filters buttons."
(telega-debug "IN: `telega-root--chat-update'")
(telega-debug "IN: `telega-root--chat-update': %s"
(telega-chat--title chat))
(with-telega-root-buffer
(goto-char (point-min))
(let ((button (telega-button-find 'telega-chat chat)))
Expand Down
15 changes: 15 additions & 0 deletions telega.el
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ With prefix arg force quit without confirmation."
:first_name ""
:last_name ""))))

(defun telega--check-password (event)
"Check the password for the 2-factor authentification."
(let* ((hint (plist-get event :password_hint))
(passwd (password-read
(concat "Telegram password"
(if (string-empty-p hint)
""
(format "(hint='%s')" hint))
": "))))
(telega-server--send
`(:@type "checkAuthenticationPassword" :password ,passwd))))

(defun telega--set-options ()
"Send `telega-options-plist' to server."
(cl-loop for (prop-name value) in telega-options-plist
Expand Down Expand Up @@ -179,6 +191,9 @@ With prefix arg force quit without confirmation."
(authorizationStateWaitCode
(telega--check-auth-code (plist-get state :is_registered)))

(authorizationStateWaitPassword
(telega--check-password event))

(authorizationStateReady
;; TDLib is now ready to answer queries
(telega--authorization-ready))
Expand Down

0 comments on commit e0cc4f4

Please sign in to comment.