Skip to content

Commit

Permalink
Merge pull request #479 from hpi-swa-teaching/fix/GH-467
Browse files Browse the repository at this point in the history
Add TFA
  • Loading branch information
jacob271 authored May 22, 2022
2 parents e6d70d1 + 8d38e24 commit 3e4de95
Show file tree
Hide file tree
Showing 53 changed files with 243 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library calls
checkAuthenticationPassword: aString

self core send: (TCCRequest newCheckAuthenticationPassword: aString).
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ handleEvent: anEvent
self isAwaitingDbEncryptionKey ifTrue: [self setDbEncryptionKey: ''].
self isAwaitingPhoneNumber ifTrue: [^ #awaitPhoneNumber].
self isAwaitingAuthCode ifTrue: [^ #awaitAuthCode].
self isAwaitingAuthPassword ifTrue: [^ #awaitAuthPassword].
self isAuthorizationStateReady ifTrue: [^ self core authSucceeded].
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
isAwaitingAuthPassword

^ self authState = 'authorizationStateWaitPassword'
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
"authState" : "R.S 5/18/2020 17:54",
"authState:" : "R.S 5/18/2020 17:54",
"checkAuthenticationCode:" : "RS 6/23/2021 16:35",
"checkAuthenticationPassword:" : "aka 5/21/2022 10:33",
"core" : "per 5/21/2021 16:57",
"core:" : "per 5/21/2021 16:57",
"handleEvent:" : "JB 6/7/2021 11:15",
"handleEvent:" : "aka 5/21/2022 11:33",
"initialize" : "RS 4/28/2021 18:04",
"isAuthStateClosed" : "r.s 7/15/2020 12:17",
"isAuthorizationStateReady" : "r.s 7/15/2020 12:17",
"isAwaitingAuthCode" : "r.s 7/15/2020 12:17",
"isAwaitingAuthPassword" : "aka 5/21/2022 10:10",
"isAwaitingDbEncryptionKey" : "8/5/2021 21:14:18",
"isAwaitingPhoneNumber" : "r.s 7/15/2020 12:17",
"isAwaitingTdlibParams" : "8/5/2021 21:14:18",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
handlers
checkAuthenticationPassword: aString

self authenticationHandler checkAuthenticationPassword: aString.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ tryHandleError: anError
['USERNAME_NOT_OCCUPIED'] -> [UIManager default inform: TCCErrorConstants unknownUsername].
['USERNAME_INVALID'] -> [UIManager default inform: TCCErrorConstants unknownUsername].
['PHONE_NUMBER_INVALID'] -> [UIManager default inform: TCCErrorConstants invalidAuthenticationCode].
['PHONE_CODE_INVALID'] -> [UIManager default inform: TCCErrorConstants invalidAuthenticationCode]}
['PHONE_CODE_INVALID'] -> [UIManager default inform: TCCErrorConstants invalidAuthenticationCode].
['PASSWORD_HASH_INVALID'] -> [UIManager default inform: TCCErrorConstants invalidAuthenticationPassword]}
otherwise: [
((anError at: 'message') beginsWith: 'Can''t lock file')
ifTrue: [UIManager default inform: TCCErrorConstants tdlibAlreadyInUse]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"chatsHandler" : "rs 6/7/2020 21:50",
"chatsHandler:" : "rs 6/7/2020 21:50",
"checkAuthenticationCode:" : "RS 7/31/2021 15:56",
"checkAuthenticationPassword:" : "aka 5/21/2022 11:31",
"client" : "R.S 5/20/2020 16:08",
"client:" : "pk 8/5/2021 16:39",
"freeClient" : "6/9/2021 14:12:18",
Expand All @@ -35,7 +36,7 @@
"send:thenDo:" : "JB 8/1/2021 11:26",
"sendPhoneNumber:" : "RS 7/31/2021 15:57",
"setUserId:" : "pk 8/5/2021 17:05",
"tryHandleError:" : "JB 6/4/2021 17:28",
"tryHandleError:" : "aka 5/21/2022 12:07",
"update" : "pk 8/5/2021 17:09",
"userStore" : "per 7/15/2021 12:56",
"userStore:" : "tr 7/25/2021 17:57" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
messages
invalidAuthenticationPassword

^ 'The password you entered seems to be invalid.'
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"class" : {
"invalidAuthenticationCode" : "r.s 7/31/2020 14:48",
"invalidAuthenticationPassword" : "aka 5/21/2022 12:06",
"invalidPhoneNumber" : "r.s 7/31/2020 14:48",
"tdlibAlreadyInUse" : "r.s 7/31/2020 14:48",
"unknownUsername" : "r.s 7/31/2020 14:48" },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
instance creation
newCheckAuthenticationPassword: aString

^ TCCRequest
newWithType: 'checkAuthenticationPassword'
from: {'password' -> aString}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"class" : {
"newCheckAuthenticationCode:" : "RS 6/23/2021 16:35",
"newCheckAuthenticationPassword:" : "aka 5/21/2022 10:34",
"newCheckDatabaseEncryptionKey:" : "RS 6/23/2021 16:35",
"newGetBasicGroupFullInfoOf:" : "JB 8/1/2021 18:17",
"newGetChatHistoryOf:from:until:" : "RS 6/24/2021 09:20",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
buttonCancel: aButton

buttonCancel := aButton.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
buttonCancel

^ buttonCancel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
event handling
buttonCancelPressed

self showPhoneNumberStep.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
buttonVerifyAuthCode: aButton

buttonVerifyAuthCode := aButton.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
buttonVerifyAuthCode

^ buttonVerifyAuthCode
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
event handling
buttonVerifyPressed
buttonVerifyAuthCodePressed

self core checkAuthenticationCode: self inputField text.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
buttonVerifyAuthPassword: aButton

buttonVerifyAuthPassword := aButton
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
buttonVerifyAuthPassword

^ buttonVerifyAuthPassword
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
event handling
buttonVerifyAuthPasswordPressed

self core checkAuthenticationPassword: self passwordField text.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
initialization
createButtonCancel

self
buttonCancel: (TCUButton new
text: 'Cancel';
center: self inputField center + ((-100) @ 50);
hide;
on: #mouseDown send: #buttonCancelPressed to: self;
yourself);
addMorph: self buttonCancel.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
initialization
createButtonVerifyAuthCode

self
buttonVerifyAuthCode: (TCUButton new
text: 'Verify';
center: self inputField center + (70 @ 50);
on: #mouseDown send: #buttonVerifyAuthCodePressed to: self;
hide;
yourself);
addMorph: self buttonVerifyAuthCode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
initialization
createButtonVerifyAuthPassword

self
buttonVerifyAuthPassword: (TCUButton new
text: 'Verify';
center: self inputField center + (70 @ 50);
on: #mouseDown send: #buttonVerifyAuthPasswordPressed to: self;
hide;
yourself);
addMorph: self buttonVerifyAuthPassword.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
initialization
createInputField: aString
createInputField

self
inputField: (TextMorph new
contentsWrapped: aString asText;
contentsWrapped: '';
extent: self class defaultInputWidth @ 50;
borderColor: TCUDefaultValues colorGray;
borderWidth: 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
initialization
createPasswordField

self
passwordField: (TextMorph new
contentsWrapped: '';
extent: self class defaultInputWidth @ 50;
borderColor: TCUDefaultValues colorGray;
borderWidth: 1;
center: self instructionLabel center + (0 @ 30);
hide;
yourself);
addMorph: self passwordField.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ initialization
initializeMorphs

self
createInputField: '+49';
createInputField;
createButtonNext;
createErrorLabel: '';
createButtonBack;
createButtonVerify.
createButtonCancel;
createButtonVerifyAuthCode;
createButtonVerifyAuthPassword;
createPasswordField.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
passwordField: aTextMorph

passwordField := aTextMorph
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
passwordField

^ passwordField
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
drawing
showSecondStep
showAuthCodeStep

self buttonNext hide.
self buttonBack show.
self buttonVerify show.

self buttonCancel show.
self buttonVerifyAuthCode show.
self instructionLabel
contents: 'Enter the code your received on your phone';
center: self center.

self inputField
contents: '';
crAction: [self buttonVerifyPressed].
show;
crAction: [self buttonVerifyAuthCodePressed].
self errorLabel hide.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drawing
showAuthPasswordStep

self buttonVerifyAuthCode hide.
self buttonCancel show.
self buttonVerifyAuthPassword show.
self inputField hide.

self instructionLabel
contents: 'Enter your password';
center: self center.

self passwordField
contents: '';
show;
crAction: [self buttonVerifyAuthPasswordPressed].
self errorLabel hide.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
drawing
showFirstStep

showPhoneNumberStep

self passwordField hide.
self buttonVerifyAuthPassword hide.
self buttonVerifyAuthCode hide.
self buttonCancel hide.

self instructionLabel
contents: 'Enter your telephone number: ' asText;
center: self center.

self buttonVerify hide.
self inputField
show;
contents: '+49';
crAction: [self buttonNextPressed].
self buttonNext show.
self instructionLabel show.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ core communication
subscribeCore

self core
when: #awaitPhoneNumber send: #showFirstStep to: self;
when: #awaitAuthCode send: #showSecondStep to: self;
when: #awaitPhoneNumber send: #showPhoneNumberStep to: self;
when: #awaitAuthCode send: #showAuthCodeStep to: self;
when: #awaitAuthPassword send: #showAuthPasswordStep to: self;
when: #authReady send: #logInCompleted to: self.
Loading

0 comments on commit 3e4de95

Please sign in to comment.