Javascript 重定向到";“下一步”;谷歌登录后。{烧瓶}
这里需要一些帮助: 上下文:我可以使用电子邮件登录没有问题。重定向和url_,以便完美地工作。 但当我用谷歌登录时。。。它正在登录,但没有重定向,因此,没有重新加载页面,没有显示注销按钮等等 相关代码: 授权登录名为“”: 顺便说一句:我知道我不应该使用谷歌的id,我还在测试它。Javascript 重定向到";“下一步”;谷歌登录后。{烧瓶},javascript,python-3.x,oauth-2.0,flask-login,Javascript,Python 3.x,Oauth 2.0,Flask Login,这里需要一些帮助: 上下文:我可以使用电子邮件登录没有问题。重定向和url_,以便完美地工作。 但当我用谷歌登录时。。。它正在登录,但没有重定向,因此,没有重新加载页面,没有显示注销按钮等等 相关代码: 授权登录名为“”: 顺便说一句:我知道我不应该使用谷歌的id,我还在测试它。 @app.route('/oauth2callback/<id>/<nome>/<email>', methods=['POST']) def oauth2callback(id,
@app.route('/oauth2callback/<id>/<nome>/<email>', methods=['POST'])
def oauth2callback(id, nome, email):
#print(f'o ID é {id}, o nome é {nome} e o email é {email}')
try:
if User().query.filter_by(email = email).first():
usuario_google = User().query.filter_by(email = email).first()
print(usuario_google)
login_user(usuario_google)
print('usuario logado')
return redirect(url_for('home', next=request.url))
else:
sessao_google = User(username=email, email=email, nome=nome)
senhas_google = Senha(senha='')
db.session.add(sessao_google)
db.session.commit()
db.session.add(senhas_google)
db.session.commit()
print('Registrado')
return redirect(url_for('login', next=request.url))
except Exception as e:
raise redirect(url_for('login'))
finally:
pass
return redirect(url_for('home'))
谢谢你的任何想法/帮助
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
var xhttps = new XMLHttpRequest();
var novaurl = 'http://localhost:5000/oauth2callback/'+profile.getId()+'/'+profile.getName()+'/'+profile.getEmail();
console.log(novaurl)
xhttps.open('POST', novaurl);
xhttps.send();
}