Skip to content

Commit

Permalink
updated authenticator
Browse files Browse the repository at this point in the history
  • Loading branch information
FePrHPI committed Jul 12, 2024
1 parent 3c5d6c9 commit 4b5dfb4
Show file tree
Hide file tree
Showing 36 changed files with 72 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ actionSubmit
areCredentialsNil := (self username isNil or: [self token isNil]).
areCredentialsNil ifTrue: [^ self errorEmptyField].

SPBGithubAPI token: self token.
oldUsername := SPBGithubAPI username.
SPBGithubAPI username: self username.
SPBAuthenticator token: self token.
oldUsername := SPBAuthenticator username.
SPBAuthenticator username: self username.

(self checkUserValid)
ifTrue: [self changed: #close]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ actions
resetCredentials
"Resets the username and token to nil to log out the user."

SPBGithubAPI
SPBAuthenticator
username: nil;
token: nil.
UserDialogBoxMorph inform: 'Credentials have been reset.' title: 'Logged out'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
token

^ token ifNil: [token := SPBGithubAPI token].
^ token ifNil: [token := SPBAuthenticator token].
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
username

^ username ifNil: [username := SPBGithubAPI username].
^ username ifNil: [username := SPBAuthenticator username].
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"open" : "jh 7/31/2022 13:05" },
"instance" : {
"actionCancel" : "mcr 7/4/2022 00:36",
"actionSubmit" : "mcr 8/4/2022 00:25",
"actionSubmit" : "FP 7/12/2024 12:58",
"buildButtons:" : "FP 6/13/2024 11:10",
"buildInputFields:" : "mcr 8/4/2022 00:18",
"buildInputPanel:" : "tk 8/2/2022 23:42",
Expand All @@ -13,10 +13,10 @@
"errorEmptyField" : "mcr 8/4/2022 00:36",
"errorUserNotFound" : "mcr 8/4/2022 00:36",
"labelString" : "lo 7/13/2022 19:29",
"resetCredentials" : "FP 6/10/2024 10:10",
"token" : "mcr 8/4/2022 00:13",
"resetCredentials" : "FP 7/12/2024 12:58",
"token" : "FP 7/12/2024 13:04",
"token:" : "lo 7/13/2022 19:26",
"updateToken:" : "mcr 8/4/2022 00:18",
"updateUsername:" : "mcr 8/4/2022 00:18",
"username" : "mcr 8/4/2022 00:12",
"username" : "FP 7/12/2024 12:57",
"username:" : "lo 7/13/2022 19:27" } }
4 changes: 4 additions & 0 deletions Squello-Core.package/SPBAuthenticator.class/class/token.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
token

^ Token.
4 changes: 4 additions & 0 deletions Squello-Core.package/SPBAuthenticator.class/class/username.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
username

^ Username
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ authenticate
self checkIfCredentialsMissing
ifTrue: [self errorAuthenticationCanceled. Error signal].

[self checkIfTokenValid]
on: Error do: [Error signal].
"this is now handled by the boardProvider"
"[self checkIfTokenValid]
on: Error do: [Error signal]."
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
authentication
checkIfCredentialsMissing

self username: SPBGithubAPI username.
self token: SPBGithubAPI token.

^ self username isNil or: [self token isNil].
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ errorGarbageToken

UserDialogBoxMorph
inform: 'Not a valid token' title: 'Operation canceled'.
SPBGithubAPI token: nil.
SPBAuthenticator token: nil.
^ Error signal.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ errorInvalidTokenScopes
UserDialogBoxMorph
inform: 'Invalid token or username or repository is private. Token has only public_repo scope'
title: 'Operation canceled'.
SPBGithubAPI token: nil.
SPBAuthenticator token: nil.
^ Error signal.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ errorNoScopes

UserDialogBoxMorph
inform: 'Make sure the token has repo or public_repo scope' title: 'Operation cancelled'.
SPBGithubAPI token: nil.
self token: nil.
^ Error signal.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
token: aString

token := aString.
self class token: aString.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
token

^ token.
^ self class token.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
username: aString

username := aString.
self class username: aString.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
username

^ username.
^ self class username.
24 changes: 14 additions & 10 deletions Squello-Core.package/SPBAuthenticator.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
{
"class" : {
"newWith:" : "mcr 8/2/2022 17:38" },
"newWith:" : "mcr 8/2/2022 17:38",
"token" : "FP 7/12/2024 12:50",
"token:" : "FP 7/12/2024 12:50",
"username" : "FP 7/12/2024 12:50",
"username:" : "FP 7/12/2024 12:50" },
"instance" : {
"authenticate" : "mcr 8/4/2022 00:26",
"authenticate" : "FP 7/12/2024 12:55",
"boardProvider" : "mcr 8/2/2022 18:26",
"boardProvider:" : "mcr 8/2/2022 18:26",
"checkIfCredentialsMissing" : "mcr 8/4/2022 02:19",
"checkIfCredentialsMissing" : "FP 7/12/2024 12:56",
"checkIfTokenValid" : "mcr 8/4/2022 02:23",
"detectInsufficientScopes:" : "mcr 8/4/2022 00:33",
"errorAuthenticationCanceled" : "mcr 8/2/2022 21:49",
"errorGarbageToken" : "mcr 8/2/2022 22:08",
"errorInvalidTokenScopes" : "mcr 8/3/2022 23:31",
"errorNoScopes" : "mcr 8/2/2022 22:31",
"errorGarbageToken" : "FP 7/12/2024 13:00",
"errorInvalidTokenScopes" : "FP 7/12/2024 13:00",
"errorNoScopes" : "FP 7/12/2024 12:52",
"errorRepoNotFound" : "mcr 8/2/2022 21:50",
"getTokenScopes" : "mcr 8/4/2022 00:34",
"token" : "mcr 8/2/2022 18:26",
"token:" : "mcr 8/2/2022 18:26",
"token" : "FP 7/12/2024 12:52",
"token:" : "FP 7/12/2024 12:52",
"tryQueryRepo" : "mcr 8/4/2022 01:12",
"username" : "mcr 8/2/2022 18:27",
"username:" : "mcr 8/2/2022 18:27" } }
"username" : "FP 7/12/2024 12:53",
"username:" : "FP 7/12/2024 12:53" } }
3 changes: 2 additions & 1 deletion Squello-Core.package/SPBAuthenticator.class/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"classinstvars" : [
],
"classvars" : [
],
"Token",
"Username" ],
"commentStamp" : "mcr 8/2/2022 22:57",
"instvars" : [
"boardProvider",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ startup
errorParsingUrl

UserDialogBoxMorph
inform: 'Invalid repository Url' title: 'Error parsing Url'.
inform: 'An error occurred when parsing the url' title: 'Error parsing Url'.
5 changes: 3 additions & 2 deletions Squello-Core.package/SPBBoard.class/class/newWith..st
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ newWith: aString
| instance |
instance := self new.

"["instance loadProject: aString."]
on: Error do: [self errorParsingUrl. ^ self]."
SPBAuthenticator new authenticate.
[instance loadProject: aString.]
on: Error do: [self errorParsingUrl. ^ self].

instance buildAndOpen.
^ instance.
4 changes: 1 addition & 3 deletions Squello-Core.package/SPBBoard.class/instance/loadProject..st
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ loadProject: aString

(aString includesSubstring: '/projects')
ifTrue: [self parseProjectFromUrl: aString]
"on: Error do: [self errorInvalidUrl.]]"
ifFalse: [[self chooseProjectFromUrl: aString]
on: Error do: [Error signal]].
ifFalse: [self chooseProjectFromUrl: aString].

self setUpChangeProvider.
6 changes: 3 additions & 3 deletions Squello-Core.package/SPBBoard.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"class" : {
"columnMinimumExtent" : "lo 8/1/2022 13:40",
"errorParsingUrl" : "mcr 8/4/2022 01:05",
"errorParsingUrl" : "FP 7/12/2024 12:40",
"lastProject" : "tk 7/30/2022 21:54",
"lastProject:" : "tk 7/30/2022 21:54",
"localPrefix" : "FP 5/27/2024 17:40",
"newLocalWith:" : "FP 6/25/2024 15:21",
"newWith:" : "FP 6/15/2024 13:20",
"newWith:" : "FP 7/12/2024 12:56",
"open" : "FP 6/10/2024 16:24",
"openFromPrompt:" : "FP 6/10/2024 16:26",
"openLocal:" : "FP 6/25/2024 15:31",
Expand Down Expand Up @@ -67,7 +67,7 @@
"initialize" : "FP 6/10/2024 14:43",
"isLocal" : "FP 6/10/2024 15:01",
"isLocal:" : "FP 6/10/2024 14:43",
"loadProject:" : "FP 6/15/2024 13:18",
"loadProject:" : "FP 7/12/2024 12:38",
"makeLocal" : "FP 6/25/2024 14:19",
"makeLocal:" : "FP 6/25/2024 14:19",
"parseLocalRepoFromUrl:" : "FP 5/27/2024 17:13",
Expand Down
2 changes: 1 addition & 1 deletion Squello-Core.package/SPBGithubAPI.class/class/token.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
token

^ Token.
^ SPBAuthenticator token.
2 changes: 1 addition & 1 deletion Squello-Core.package/SPBGithubAPI.class/class/username.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
username

^ Username.
^ SPBAuthenticator username.
6 changes: 2 additions & 4 deletions Squello-Core.package/SPBGithubAPI.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"class" : {
"token" : "mcr 5/27/2022 23:06",
"token:" : "mcr 5/27/2022 23:06",
"username" : "mcr 5/28/2022 00:49",
"username:" : "mcr 5/27/2022 23:06" },
"token" : "FP 7/12/2024 13:02",
"username" : "FP 7/12/2024 13:02" },
"instance" : {
"addAssignee:toIssue:user:repo:" : "FP 6/15/2024 13:40",
"addIssue:toColumn:" : "lo 6/6/2022 12:51",
Expand Down
3 changes: 1 addition & 2 deletions Squello-Core.package/SPBGithubAPI.class/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"classinstvars" : [
],
"classvars" : [
"Token",
"Username" ],
],
"commentStamp" : "LW 6/20/2022 10:00",
"instvars" : [
],
Expand Down
4 changes: 0 additions & 4 deletions Squello-Core.package/SPBNewGithubAPI.class/class/token..st

This file was deleted.

2 changes: 1 addition & 1 deletion Squello-Core.package/SPBNewGithubAPI.class/class/token.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
token

^ Token.
^ SPBAuthenticator token.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
errors
authError

UserDialogBoxMorph
inform: 'Please make sure that your token has a suffient scope for this project.' title: 'Insufficient token scope'.
^ Error signal.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ queryProjectID: aNumber user: aString
| data responseJson |
data := (self getQueryProjectIDQuery: aNumber user: aString) parseAsJson.
responseJson := self postRequestwithData: data.
(responseJson at: 'data') ifNil: [self authError.].
^ (((responseJson at: 'data') at: self userString) at: 'projectV2') at: 'id'.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"class" : {
"token" : "FP 6/13/2024 16:49",
"token:" : "FP 6/13/2024 16:49",
"token" : "FP 7/12/2024 12:45",
"url" : "FP 6/15/2024 13:47" },
"instance" : {
"addAssignee:toIssue:" : "FP 6/18/2024 12:12",
"addLabel:toIssue:" : "FP 6/18/2024 13:51",
"authError" : "FP 7/12/2024 12:40",
"createPostRequestTo:" : "FP 6/13/2024 16:58",
"deleteAssignee:fromIssue:" : "FP 6/18/2024 11:18",
"deleteLabel:fromIssue:" : "FP 6/18/2024 13:59",
Expand Down Expand Up @@ -34,7 +34,7 @@
"queryColumnFieldId:" : "FP 6/19/2024 17:30",
"queryColumns:" : "FP 6/19/2024 17:36",
"queryProject:" : "FP 6/16/2024 15:40",
"queryProjectID:user:" : "FP 6/16/2024 15:28",
"queryProjectID:user:" : "FP 7/12/2024 12:37",
"updateAssignees:fromDraft:" : "FP 6/18/2024 12:15",
"updateCardPosition:after:inProject:" : "FP 6/19/2024 18:16",
"updateDraft:" : "FP 6/18/2024 15:04",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ tests
testActionToken

| token |
self assert: SPBGithubAPI token equals: auth token.
self assert: SPBAuthenticator token equals: auth token.

token := 'SeCrEtToKeN'.
auth updateToken: token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ testActionUsername

| user |

self assert: SPBGithubAPI username equals: auth username.
self assert: SPBAuthenticator username equals: auth username.

user := 'Username'.
auth updateUsername: user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"instance" : {
"setUp" : "mcr 8/2/2022 23:01",
"tearDown" : "jh 6/3/2022 20:57",
"testActionToken" : "mcr 8/4/2022 02:31",
"testActionUsername" : "mcr 8/4/2022 02:32",
"testActionToken" : "FP 7/12/2024 12:58",
"testActionUsername" : "FP 7/12/2024 13:00",
"testBuildWith" : "mcr 7/4/2022 00:44",
"testLabelString" : "lo 7/13/2022 19:29",
"testToken" : "mcr 8/4/2022 02:39",
Expand Down

0 comments on commit 4b5dfb4

Please sign in to comment.