如何检查用户名/密码组合对于FOS UserBundle是否有效 [英] How to check if a username/password combination is valid for FOS UserBundle

查看:77
本文介绍了如何检查用户名/密码组合对于FOS UserBundle是否有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前正在使用Symfony 2和FOS/UserBundle进行用户身份验证.

We are currently using Symfony 2 and FOS/UserBundle for user authentication.

我想检查给定的用户名/密码组合是否有效,而无需登录.这是因为当前正在登录另一个人,但是例如需要执行特定的操作,而该操作必须由具有较高权限的人员执行.

I want to check if a given username/password combination is valid without logging in. This is because another person is currently logged in but for example needs to do a specific action which needs to be done by someone with a higher clearance.

基本上,我希望其他用户除了当前登录的用户之外执行其他控制器操作.

Basically I want another user to do a different controller action besides the person that is currently logged.

如果有更好的方法,请告诉我

If there's a better way of doing this please let me know

推荐答案

如何验证用户名和密码来自控制器#696

public function validUser($username, $password){

    $user = new Users();    //entity

    $factory = $this->get('security.encoder_factory');
    $encoder = $factory->getEncoder($user);

    $bool = $encoder->isPasswordValid($user->getPassword(),$password,$user->getSalt());
}

这篇关于如何检查用户名/密码组合对于FOS UserBundle是否有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆