Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tell, Don't Ask Principle and Password Expiration

Trying to keep with pragmatic programming principles, I'm trying to decide on how to handle user password changes based on the "Tell, Don't Ask" principle.

I have a user object whose password expires every 30 days. I need to be able to show a password expired/change password view if the password is expired. Asking the object if the password is expired (it's state) and then choosing which view to show seems like a violation of the principle.

What is the best way to handle this situation?

like image 402
Hupperware Avatar asked Mar 26 '12 19:03

Hupperware


People also ask

Why is my Microsoft password expiring?

If you have received an email with a subject line something like, "Office 365 Password About to Expire" claiming that your account's password is about to expire, THIS IS A PHISHING SCAM being sent by cybercriminals and not by Microsoft.

How do I change my password expiration in Salesforce?

Required Editions and User Permissions To expire passwords for all users, except those users with profiles that have the Password Never Expires user permission: From Setup, enter Expire All Passwords in the Quick Find box, then select Expire All Passwords. Select Expire all user passwords. Click Save.

Do not expire passwords?

Set password expiration policy Select Password expiration policy. If you don't want users to have to change passwords, uncheck the box next to Set passwords to never expire. Type how often passwords should expire.


1 Answers

login
   model.validate();
   return model.show(self);

passwordExpired()
  return View("ChangePassword")

loginSuccess()
  return View("default")

class User
  show(aController)
      if passwordExpired
          return aContoller.passwordExpired()
     else return aContoller.loginSuccess()

Tell, Don't Ask, no exceptions, and it obeys the law of Demeter

like image 142
Hupperware Avatar answered Nov 07 '22 19:11

Hupperware