简体   繁体   English

GitHub项目“ FirebaseUI for Web — Auth”是否有一个'signInFailureUrl'参数

[英]Is there a 'signInFailureUrl' parameter for GitHub project “FirebaseUI for Web — Auth”

I am extremely new to code. 我对代码非常陌生。 I am using firebase's firebase UI github project to handle my email/password authentication — https://github.com/firebase/firebaseui-web . 我正在使用firebase的firebase UI github项目来处理我的电子邮件/密码身份验证— https://github.com/firebase/firebaseui-web Redirect is working, but how do I prevent a user from bypassing the login page and simply visiting the "successful" url (if someone were to simply share it with them). 重定向有效,但是如何防止用户绕过登录页面并仅访问“成功” URL(如果有人与他们共享)。 My hope was to be able to simply set a 'signInFailureUrl' parameter. 我希望能够简单地设置一个'signInFailureUrl'参数。 But it didn't work,haha. 但这没用,哈哈。 Below, I've pasted the config object where I set the 'signInSuccessUrl.' 在下面,我将配置对象粘贴到设置“ signInSuccessUrl”的位置。 How can I handle this? 我该如何处理? Any help would be greatly appreciated. 任何帮助将不胜感激。

var uiConfig = {
    'queryParameterForWidgetMode': 'mode',
    // Query parameter name for sign in success url.
    'queryParameterForSignInSuccessUrl': 'signInSuccessUrl',
    'signInSuccessUrl': '<url-to-redirect-to-on-success>',
    'singInFailureUrl': '<url-to-redirect-to-on-failure>',
    'signInOptions': [
      // I am only using email and password for my app
      firebase.auth.EmailAuthProvider.PROVIDER_ID
    ],
    'callbacks': {
      'signInSuccess': function(currentUser, credential, redirectUrl) {
        return true;
      }
    }
  };

With Firebase using the correct database permissions, only the owner of the data will be able to access it. 使用正确的数据库权限的Firebase,只有数据所有者才能访问它。 So if the user goes to the protected page, only their data will be populated. 因此,如果用户转到受保护的页面,则只会填充其数据。 If the user is not logged in, the data will not be served at all. 如果用户未登录,则将完全不提供数据。 This is all done on the front end. 这些都是在前端完成的。 If you do not wish to use Firebase database to serve your data, you can instead, on the protected page, attach a listener: 如果您不想使用Firebase数据库来提供数据,则可以在受保护的页面上附加一个侦听器:

firebase.auth().onAuthStateChanged(function(user) { if (user) { user.getToken(function(token) { // send this token to user server when loading the // restricted content via xhr. // On the backend server, use the currently available backend // libraries to validate the token and then serve the user's // data. // https://firebase.google.com/docs/auth/server/verify-id-tokens }); } });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM