def auth_user_oauth(self, userinfo):
if "<STR_LIT:username>" in userinfo:<EOL><INDENT>user = self.find_user(username=userinfo["<STR_LIT:username>"])<EOL><DEDENT>elif "<STR_LIT:email>" in userinfo:<EOL><INDENT>user = self.find_user(email=userinfo["<STR_LIT:email>"])<EOL><DEDENT>else:<EOL><INDENT>log.error("<STR_LIT>".format(userinfo))<EOL>return None<EOL><DEDENT>if user and not user.is_active:<EOL><INDENT>log.info(LOGMSG_WAR_SEC_LOGIN_FAILED.format(userinfo))<EOL>return None<EOL><DEDENT>if not user and not self.auth_user_registration:<EOL><INDENT>return None<EOL><DEDENT>if not user:<EOL><INDENT>user = self.add_user(<EOL>username=userinfo["<STR_LIT:username>"],<EOL>first_name=userinfo.get("<STR_LIT>", "<STR_LIT>"),<EOL>last_name=userinfo.get("<STR_LIT>", "<STR_LIT>"),<EOL>email=userinfo.get("<STR_LIT:email>", "<STR_LIT>"),<EOL>role=self.find_role(self.auth_user_registration_role),<EOL>)<EOL>if not user:<EOL><INDENT>log.error("<STR_LIT>" % userinfo["<STR_LIT:username>"])<EOL>return None<EOL><DEDENT><DEDENT>self.update_user_auth_stat(user)<EOL>return user<EOL>
OAuth user Authentication

:userinfo: dict with user information the keys have the same name
as User model columns.