I have to implement the Two Factor Authentication. I have searched the forum and a Topic Two-factor authentication - #2 от пользователя b.tel - CUBA.Platform which explains how to do it.
I did it the same way with some modifications for Cuba 7. But I’m getting the below error in the Settings screen when enabling the 2 Factor Authentication for the user.
java.lang.ClassCastException: com.haulmont.cuba.security.entity.User cannot be cast to com.company.scoringsystem.entity.ExtUser
The log file is attached. Also my ExtUser, ExtSettings java file is attached.
error.txt (4.5 KB)
ExtUser.java (874 Bytes)
ExtAppLoginWindow.java (2.8 KB)
ExtSettingsWindow.java (3.1 KB)
Thanks,
Hari
b.tel
(Berend Tel)
June 18, 2019, 2:06pm
#2
Hi,
Did you extend the user using Cuba studio? If not, I would hardly recommend doing so.
It would also be interesting to see during execution (using a debugger) whether or not a user is returned from the user session.
-b
Hi Berend,
I did use Cuba studio to extend it.
Thanks,
Hari
I did debug, the user is return from the user session too.
I thought adding @Extends annotation would help.
If I add the below line of code to ExtUser.java, server doesn’t start and getting struck at the login screen.
@Extends (User.class)
I get the below error in the console.
Unknown login name or bad password ‘anonymous’
Can some one let me know when this Class cast exception will occur between ExtUser and User classes?
b.tel
(Berend Tel)
June 18, 2019, 5:18pm
#7
Hi,
Unfortunately I’m still on version 6 of the platform and am unable to check it out. Help from a Cuba support engineer or somebody with experience on extending entities in 7 would be needed I guess.
-b
b.tel
(Berend Tel)
June 18, 2019, 5:28pm
#8
You might want to take a look here: multitenancy-addon/TenantUser.java at master · cuba-platform/multitenancy-addon · GitHub as it provides a user extension for the multitenancy in platform 7.
-b
The issue is resolved. I have done the below to resolve the issue.
Added @Extends to the ExtUser Class - This resulted in another error.
Then I have update the init script to update DTYPE column to the value present in the ExtUser class.
Then dropped the database and rerun the scripts
I was wondering why @Extends doesn’t generate when it has been done through Cuba Studio only.
Also I will compile these codes as a pluggin and release a Two Factor Authentication in the market place when I’m free.
Thanks,
Hari
1 Like