gate-sso / gate

Gate is MFA Enabled SSO Platform that supports SAML, OAuth, Linux shell login and CAS
https://gate-sso.github.io
MIT License
203 stars 53 forks source link

Optimize passwd api #166

Closed walbertus closed 5 years ago

walbertus commented 5 years ago

When not responding to gid on respond_to?(:gid) && gid because gid is actually nil.

The checking goes to user_hash[:pw_gid] = groups.where(name: user_login_id).first.gid if groups.where(name: user_login_id).count > 0 which will call query to count over and over even though the result is 0 (this is why gid is nil).

Add a query to count the number of gid in the previous step to make sure the program doesn't search the gid by telling that the gid count is actually 0.

@giosakti