Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions api/src/Authentication/Type/OIDC.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ function authenticateByCode($code)
'samesite' => 'Strict'
);

setcookie($cookie_key, $token, $cookieOpts);
return $this->getUser($token);
$user = $this->getUser($token);

if ($user) {
setcookie($cookie_key, $token, $cookieOpts);
}

return $user;
}

function logout()
Expand Down
6 changes: 4 additions & 2 deletions api/src/Controllers/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ function check()
{
$this->returnResponse(200, $this->generateJwtToken($userId));
}
} else if ($userId === null) {
$this->returnError(403, 'User not recognised');
}
$this->returnError(400, 'No previous session');
}
Expand Down Expand Up @@ -358,7 +360,7 @@ function authorise()

if ($cas_sso) {
header('Location: ' . $this->authenticateByType()->authorise());
$this->returnResponse(302, array('status' => "Redirecting to CAS"));
$this->returnResponse(302, array('status' => "Redirecting to provider"));
} else {
$this->returnError(501, "SSO not configured");
}
Expand All @@ -379,7 +381,7 @@ function authenticateByCode()
}
$this->returnResponse(200, $this->generateJwtToken($fedid));
} else {
$this->returnError(401, 'Invalid Credentials');
$this->returnError(403, 'User not recognised');
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/tests/Controllers/AuthenticationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testCodeAuthenticationInitiallyFailsWhenAuthenticationTypeReturn
});

$this->assertContains('Content-Type: application/json', Output::$headers);
$this->assertContains('X-PHP-Response-Code: 401', Output::$headers);
$this->assertContains('X-PHP-Response-Code: 403', Output::$headers);
}

public function testCodeAuthenticationWhenGetValidFedIdReturnsSuccess(): void
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/app/store/modules/store.auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const auth = {
},
error: function(req, status, error) {
commit('authError')
reject(error)
reject(req)
},
complete: function() {
commit('loading', false, { root: true })
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/app/views/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default {
.dispatch("auth/getToken", token)
.then(() => this.$router.push(actualRedirectUrl))
.catch((e) => {
if (e === "Forbidden") {
if (e.status === 403) {
this.authError = "not-recognised";
}
});
Expand Down
Loading