开发者

Postgres Rule to invalidate user passwords every 60 days

I am having some trouble invalidating user passwords every 60 days on my postgres database:

CREATE RULE user_expiration AS ON UPDATE TO users DO INSTEAD 开发者_运维问答 UPDATE user SET user_expires = user_expires + '60'

This will work every time the user changes their password, however it also works every time any update is issued on the records. How can I ensure that it only updates on the change password event?


A trigger is a better solution. As of version 9.0 it has per column triggers, triggers that only fire when a certain column has been changed. In older versions you have to do the check inside the function, compare OLD.password and NEW.password before you deside to update the user_expires column.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜