Encrypt and decrypt user phone at model level
Summary
The implementation of phone encryption is not designed to encapsulate the details at model level at the beginning, now days, we have more and more code like Gitlab::CryptoHelper.aes256_gcm_decrypt(params[:user][:phone])
everywhere.
The length of a phone number should be between 7 and 15 according to "Regular Expressions Cookbook, 2nd Edition by Jan Goyvaerts, Steven Levithan"
Thanks to the international phone numbering plan (ITU-T E.164), phone numbers cannot contain more than 15 digits. The shortest international phone numbers in use contain seven digits.
Proposal
-
Re-implement phone encryption and decryption on user model. -
Replace all parts with the new implementation above
由 Martin Tan 编辑于