Closed hirunatan closed 2 years ago
Why you think that my app is reason of your problem ?
From the trace call stack:
{
"file": "/app/data/apps/sociallogin/lib/Db/ConnectedLoginMapper.php",
"line": 56,
"function": "insert",
"class": "OCP\\\\AppFramework\\\\Db\\\\QBMapper",
"type": "->"
},
The error seems to occur inside the sociallogin app. And also it happens while processing the redirect_api call at /apps/sociallogin/oauth/google
url, that is also likely to be from this app. Isn't it?
You configure my app, your DB can not insert record, and I am guilty ? Just disable my app if you think so.
Or tell what EXACTLY you does.
Sorry was nervous. Are you using DB in container that may be restarted after login flow is started and before it finished ?
Ok, no problem. Anyone may have a bad day, if this does not happen very often it doesn't matter :smiley:
I use nextcloud with the social-login app inside a docker container, and I think that it does not restart any time. I use PostgreSQL as the database.
I have investigated it a bit further. The error occurs in sociallogin/lib/Db/ConnectedLoginMapper.php, the function is
public function connectLogin($uid, $identifier)
{
$l = new ConnectedLogin();
$l->setUid($uid);
$l->setIdentifier($identifier);
$this->insert($l);
}
This executes an insert, that at some point calls lastInsertId function, that is defined here in the PgSql adapter:
public function lastInsertId($table) {
$result = $this->conn->executeQuery('SELECT lastval()');
$val = $result->fetchOne();
$result->free();
return (int)$val;
}
The insert function uses lastInsertId to return the id of the newly inserted row. BUT this lastval()
function used assume that the table we are on has a PK that is a serial sequence field. If there is no serial field in the table, it causes the given error "lastval is not yet defined".
I'm not sure, but it seems that the table being used for social login (I think 'sociallogin_connect' is the name) perhaps has a PK that is not a serial sequence. Could it be? I don't understand the code very well so I can't state it firmly. But perhaps you have any clue about this, you know well the app. Do you think this could be the cause of the failure?
Thanks for your patience and your help!
Check v4.9.1 Thanks for investigations, it helps.
Ey, thanks very much! It seems to work well now, after updating to new version. Good work!
Hello. I have set up login with google in my nextcloud instance. It works OK except that, when google calls back to the redirect_uri after connecting an existing account, it shows a 500 error page. Looking at server logs, I see an error with this message in the php log of the nextcloud app:
"An exception occurred while executing a query: SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: lastval is not yet defined in this session"
These are my versions: nextcloud 22.2.0 social-login 4.8.10 postgresql 12.5
Any clue? Thanks very much!
This is the full error trace (i have removed personal info and keys):