Skip to content

Commit 5c70281

Browse files
committed
Merge branch 'develop' of github.com:Unipisa/caps into develop
2 parents 8b61f80 + 7750af1 commit 5c70281

7 files changed

Lines changed: 999 additions & 153 deletions

File tree

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: push
44

55
jobs:
66
docker:
7-
runs-on: ubuntu-latest
7+
runs-on: ubuntu-22.04
88
steps:
99
- uses: actions/checkout@v2
1010
- name: JS tests

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ presso il Dipartimento di Matematica, Università di Pisa.
77
Per informazioni sullo sviluppo di CAPS, si veda [DEVELOP.md](DEVELOP.md). È possibile provare
88
ad utilizzare CAPS anche tramite le immagini [Docker](https://github.com/unipisa/caps/pkg/container/caps),
99
per cui sono disponibile [istruzioni specifiche](https://github.com/Unipisa/caps/blob/develop/docker/README.md).
10-

backend/src/Controller/UsersController.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,35 @@ private function login_user($authuser) {
131131
$user = $this->Users->newEmptyEntity();
132132
}
133133

134-
// We save the user data no matter what, just in case it has changed
135-
// since the last update.
136-
$user = $this->Users->patchEntity($user, [
137-
'name' => ucwords(strtolower($authuser['name'])),
134+
$patchData = [
135+
// 'name' => ucwords(strtolower($authuser['name'])),
138136
'username' => $authuser['username'],
139137
'number' => $authuser['number'],
140-
'surname' => $authuser['surname'],
141-
'givenname' => $authuser['givenname'],
138+
// 'surname' => $authuser['surname'],
139+
// 'givenname' => $authuser['givenname'],
142140
'email' => $authuser['email'],
143141
'admin' => $user ? $user['admin'] : $authuser['admin'] // We only use the database admin flag
144142
// if the user is not found; otherwise a user might have been granted admin privileges
145143
// locally and we respect that.
146-
]);
144+
];
145+
146+
// If we get new data for givenname, surname, name, overwrite what we have in the database.
147+
if (isset($authuser['surname']) || isset($authuser['givenname']) || $user->isNew()) {
148+
$patchData['name'] = ucwords(strtolower($authuser['givenname'] . ' ' . $authuser['surname']));
149+
}
150+
if (isset($authuser['surname']) || $user->isNew()) {
151+
$patchData['surname'] = $authuser['surname'];
152+
}
153+
if (isset($authuser['givenname']) || $user->isNew()) {
154+
$patchData['givenname'] = $authuser['givenname'];
155+
}
156+
if (isset($authuser['number']) || $user->isNew()) {
157+
$patchData['number'] = $authuser['number'];
158+
}
159+
160+
// We save the user data no matter what, just in case it has changed
161+
// since the last update.
162+
$user = $this->Users->patchEntity($user, $patchData);
147163

148164
if ($this->Users->save($user)) {
149165
$this->Authentication->setIdentity($user);
@@ -330,7 +346,10 @@ public function oauth2Callback() {
330346

331347
// Make sure that if we have no information on the user id
332348
// in the system, we fall back to using the user id.
333-
$number = $number == "" ? $uid : $number;
349+
$number = $number == "" ? null : $number;
350+
351+
352+
$given_name = $data['given_name'] ?? '';
334353

335354
$authuser = [
336355
'username' => $uid,

docker/docker-compose-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ services:
3737
container_name: caps-db
3838
env_file:
3939
- caps.env
40-
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
40+
# command: --default-authentication-plugin=mysql_native_password
4141
volumes:
4242
- ./database:/var/lib/mysql
4343
cap_add:

0 commit comments

Comments
 (0)