2012-11-26 18:17
浏览 44

用另一个应用程序验证Drupal 7用户?

So essentially part of my company's web site is run off of Drupal 7 plus the commerce plugin. I am wondering if there is a safe way to utilize the users already existing in this system in other parts of the website that are not using Drupal. This is to avoid having two separate user accounts for one single user due to lack of communication between the programs. Is there a safe way to authehnticate users in my application based on information from the Drupal database or a standard way of going about this? The Drupal backing database is a large, strange, complicated behemoth, and I would prefer not to anger it.

The only thing I need to do is determine whether a user's credentials are valid if they login via my authentication form. If I can do this by using the Drupal login system (perhaps by passing a url to forward to afterwards) that would be excellent. Or is there a script that already manages this?

I would also like to be able to determine whether a user has already logged in and is still remember based on the cookie that I am sure the Drupal software sets.

References, applicable scripts I can use in the Drupal core, etc would be much appreciated. I am a person who knows nothing about Drupal, but have good PHP/knowledge as I have been doing web development professionally for several years.

图片转代码服务由CSDN问答提供 功能建议

因此,基本上我公司网站的一部分是使用Drupal 7和商业插件运行的。 我想知道是否有一种安全的方法来利用本系统中已存在的用户在网站的其他部分没有使用Drupal。 这是为了避免由于程序之间缺乏通信而为单个用户设置两个单独的用户帐户。 有没有一种安全的方法来根据Drupal数据库中的信息或标准的方式来验证我的应用程序中的用户? Drupal支持数据库是一个庞大,奇怪,复杂的庞然大物,我不想激怒它。

我唯一需要做的就是确定用户的凭据是否有效 通过我的身份验证表单登录 如果我可以通过使用Drupal登录系统(可能通过传递URL转发到之后)来做到这一点,这将是非常好的。 或者是否有一个已经管理过的脚本?

我还希望能够确定用户是否已经登录并且仍然记得基于我确定的cookie Drupal软件集。

我可以非常感谢参考资料,我可以在Drupal核心中使用的适用脚本等。 我是一个对Drupal一无所知但对PHP知识很好的人,因为我已经专业地进行了几年的Web开发。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongshanji3102 2012-11-26 18:44

    Yep it is easy, you can do it one of two ways.

    Option 1, use the Services module and you can use REST to login/authenticate users.

    Option 2, you can write custom code. You would either include the Drupal Boostrap or individual files you need from the user module. Then simply use the user_authenticate() function to check username and password.

    点赞 打赏 评论
  • douwen5681 2012-11-26 21:41

    you can also user xml with the services module , see details here

    点赞 打赏 评论
  • douzhang1926 2013-06-25 05:26

    With PHP using Drupal bootstrap
    this file should be inside drupal installation
    It is hell easy

    //set the working directory to your Drupal root
    define("DRUPAL_ROOT",     "/var/www/drupal/");
    //require the bootstrap include
    require_once 'includes/';
    //Load Drupal
    //(loads everything, but doesn't render anything)
    $name = 'admin';
    $password = 'admin';
    //use drupal user_authenticate function
    if(!user_authenticate($name, $password)){
        echo 'invalid';
        echo 'valid';
    点赞 打赏 评论

相关推荐 更多相似问题