Repository: psychopy/psychopy

Issue:
Psychopy3 error on Plavovia.org -> User -> Log in (AttributeError: 'NoneType' object has no attribute 'username')
Sorry if the error is already posted, I looked for open/closed issues, but couldn't find the exact error.

After a clean install, I'm unable to log in Pavlovia.org, the program crash with the following error:

```python
Traceback (most recent call last):
  File "/home/schica/side_projects/brain_auth/venv/lib/python3.8/site-packages/psychopy/app/pavlovia_ui/menu.py", line 121, in onLogInPavlovia
    logInPavlovia(parent=self.parent)
  File "/home/schica/side_projects/brain_auth/venv/lib/python3.8/site-packages/psychopy/app/pavlovia_ui/functions.py", line 62, in logInPavlovia
    dlg = PavloviaMiniBrowser(parent=parent, loginOnly=True)
  File "/home/schica/side_projects/brain_auth/venv/lib/python3.8/site-packages/psychopy/app/pavlovia_ui/_base.py", line 79, in __init__
    self.user = pavlovia.getCurrentSession().user
  File "/home/schica/side_projects/brain_auth/venv/lib/python3.8/site-packages/psychopy/projects/pavlovia.py", line 442, in user
    if not hasattr(self.gitlab, "user") or self.gitlab.user.username is None:
AttributeError: 'NoneType' object has no attribute 'username'
```
![Peek 2022-09-06 12-52](https://user-images.githubusercontent.com/9284124/188617369-6d436b91-2571-4566-9c65-6b4d4d50dadf.gif)

I've removed the folders in ~/.cache/psychopy and ~/.psychopy3 just in case, however, the error persists.

Note: I've noticed a warning in the Psychopy Runner if that's relevant
```
9.6408     WARNING     Couldn't connect to psychopy.org
Check internet settings (and proxy setting in PsychoPy Preferences
```

pip list:
```
Package                  Version
------------------------ ------------
arabic-reshaper          2.1.3
astunparse               1.6.3
cachetools               5.2.0
certifi                  2022.6.15
cffi                     1.15.1
charset-normalizer       2.1.1
cryptography             37.0.4
cycler                   0.11.0
decorator                4.4.2
distro                   1.7.0
dukpy                    0.2.3
egi-pynetstation         0.0.0rc1
esprima                  4.0.1
et-xmlfile               1.1.0
ffpyplayer               4.3.5
fonttools                4.37.1
freetype-py              2.3.0
future                   0.18.2
gevent                   21.12.0
gitdb                    4.0.9
GitPython                3.1.27
glfw                     2.5.4
google-api-core          2.10.0
google-auth              2.11.0
google-cloud             0.34.0
google-cloud-speech      2.15.1
googleapis-common-protos 1.56.4
greenlet                 1.1.3
grpcio                   1.48.1
grpcio-status            1.48.1
idna                     3.3
imageio                  2.21.2
imageio-ffmpeg           0.4.7
javascripthon            0.12
jedi                     0.18.1
json-tricks              3.15.5
kiwisolver               1.4.4
markdown-it-py           2.1.0
matplotlib               3.5.3
mdurl                    0.1.2
moviepy                  1.0.3
msgpack                  1.0.4
msgpack-numpy            0.4.8
ntplib                   0.4.0
numexpr                  2.8.3
numpy                    1.23.2
opencv-python            4.6.0.66
openpyxl                 3.0.10
packaging                21.3
pandas                   1.4.4
parso                    0.8.3
Pillow                   9.2.0
pip                      22.2.2
pkg_resources            0.0.0
proglog                  0.1.10
proto-plus               1.22.1
protobuf                 4.21.5
psutil                   5.9.1
PsychoPy                 2022.2.4
psychtoolbox             3.0.18.2
pyasn1                   0.4.8
pyasn1-modules           0.2.8
pycparser                2.21
pygame                   2.1.2
pyglet                   1.4.11
pyo                      1.0.4
pyparallel               0.2.2
pyparsing                3.0.9
PyQt5                    5.15.7
PyQt5-Qt5                5.15.2
PyQt5-sip                12.11.0
pyserial                 3.5
python-bidi              0.4.2
python-dateutil          2.8.2
python-gitlab            3.9.0
python-vlc               3.0.16120
python-xlib              0.31
pytz                     2022.2.1
PyYAML                   6.0
pyzmq                    23.2.1
questplus                2019.4
requests                 2.28.1
requests-toolbelt        0.9.1
rsa                      4.9
scipy                    1.9.1
setuptools               65.3.0
six                      1.16.0
smmap                    5.0.0
sounddevice              0.4.5
SoundFile                0.10.3.post1
SpeechRecognition        3.8.1
tables                   3.7.0
tobii-research           1.10.1
tqdm                     4.64.0
ujson                    5.4.0
urllib3                  1.26.12
websocket-client         1.4.0
wheel                    0.37.1
wxPython                 4.2.0
xarray                   2022.6.0
xlrd                     2.0.1
zope.event               4.5.0
zope.interface           5.4.0
```

neofetch:
```
schica@laptop-work 
------------------ 
OS: Linux Mint 20.3 x86_64 
Host: dynabook TECRA X40-F PMR31E-0PC00DCE 
Kernel: 5.17.5-051705-generic 
Uptime: 52 mins 
Packages: 3604 (dpkg), 7 (flatpak) 
Shell: zsh 5.8 
Resolution: 1920x1080, 1920x1080 
DE: Xfce 
WM: Xfwm4 
WM Theme: Mint-Y-Dark-Teal 
Theme: Mint-Y-Dark-Teal [GTK2/3] 
Icons: Mint-Y-Dark-Teal [GTK2/3] 
Terminal: tmux 
CPU: Intel i7-8565U (8) @ 2.000GHz 
GPU: Intel UHD Graphics 620 
Memory: 4620MiB / 31868MiB 
```


Discussion:
Great issue reporting! :-)
We'll look into it

Resolving patch:
diff --git a/psychopy/projects/pavlovia.py b/psychopy/projects/pavlovia.py
--- a/psychopy/projects/pavlovia.py
+++ b/psychopy/projects/pavlovia.py
@@ -439,7 +439,7 @@ def startSession(self, token):
     @property
     def user(self):
         if not hasattr(self, "_user") or self._user is None:
-            if not hasattr(self.gitlab, "user") or self.gitlab.user.username is None:
+            if not hasattr(self.gitlab, "user") or not hasattr(self.gitlab.user, "username") or self.gitlab.user.username is None:
                 return None
             self._user = User(self.gitlab.user.username)
         return self._user


Test patch: