简体   繁体   English

限制同时连接到同一用户帐户的数量

[英]Limit number of simultaneous connections to same user account

I have been hired to work on an existing site built in Laravel, which is a platform for real estate agents. 我受雇在Laravel建立的现有网站上工作,该网站是房地产经纪人的平台。

There are two account types - the cheap "individual agent" account and the more expensive "enterprise" account which is meant to be used by real estate agencies. 有两种帐户类型-便宜的“个人代理”帐户和更昂贵的“房地产”帐户,这些帐户将由房地产代理商使用。

Everything is generally working well, however it has come to my client's attention that some real estate agencies are exploiting the system by having one person sign up for an individual account and then handing out the username/password to all their employees, sometimes 30 or 40 of them. 一切通常都运行良好,但是引起我客户的注意的是,一些房地产经纪人正在利用该系统,方法是让一个人注册一个个人帐户,然后将用户名/密码分发给所有员工,有时是30或40其中。

This is cheating because the "enterprise" account type exists specifically for this purpose. 这是作弊的,因为“企业”帐户类型专门用于此目的。

My question - is it possible to limit the number of simultaneous logins to the same account? 我的问题-是否可以限制同时登录同一帐户的次数? For example, I would like to set the maximum number of concurrent sessions for an individual-type account to 2. Then, if a 3rd login to the same account is attempted, it is declined by the website with an appropriate message. 例如,我想将单个类型帐户的最大并发会话数设置为2。然后,如果尝试第三次登录到同一帐户,则该网站会拒绝并显示一条适当的消息。

I've been looking for solutions online, however they are either based on IP checks or some convoluted Apache/nginx config which I don't think applies to this case. 我一直在寻找在线解决方案,但是它们要么基于IP检查,要么基于一些复杂的Apache / nginx配置,我认为这种配置不适用于这种情况。 Note that the users may or may not be logging in from the same IP, so any IP-based checks are useless in this case. 请注意,用户可能会或可能不会从同一IP登录,因此在这种情况下,任何基于IP的检查都是无用的。

I am primarily looking for a solution native to PHP/Laravel, if not possible then please feel free to suggest any alternatives. 我主要是在寻找PHP / Laravel固有的解决方案,如果不可能的话,请随时提出任何替代方案。

Did you try to extend the sendLoginResponse method inside the LoginController? 您是否尝试在LoginController内扩展sendLoginResponse方法? Do you have different models for your users? 您有针对用户的不同型号吗? or are you using only the User Model with attributes? 还是仅使用具有属性的用户模型? You could do something similar to this over here: https://laracasts.com/discuss/channels/laravel/restricting-user-to-one-session-laravel-53 I wanted to write a comment, not an answer but I'm still not able to. 您可以在此处执行类似的操作: https : //laracasts.com/discuss/channels/laravel/restricting-user-to-one-session-laravel-53我想写评论,而不是回答,但我想米仍然不能。 I'll help if you give me more information. 如果您给我更多信息,我会帮助。

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

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