How to do username case insensitive in login form?

本小妞迷上赌 提交于 2021-02-08 06:37:33

问题


I'm using the login form from Symfony, but I can't login, if the entered username is 'FOO' and in the DB is stored 'foo'. I'm using Postgres. It means the username-field is case sensitive. What can I do?


回答1:


This depends mainly on your Database-Server. MySQL is case insensitive, PostgreSQL is case sensitive.

But you can write query Like this

$this->createQueryBuilder('user')
            ->where('LOWER(user.username) = :username')
            ->setParameter('username', strtolower($username))
            ->getQuery()
            ->getResult()
            ;



来源:https://stackoverflow.com/questions/56183229/how-to-do-username-case-insensitive-in-login-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!