From 25f8b547e5964934a90fe6e0d3a66f59ee50a882 Mon Sep 17 00:00:00 2001 From: Zachary Chai Date: Thu, 24 Nov 2016 17:42:08 -0500 Subject: [PATCH] modify encrypted id --- app/models/user.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 873a2b6f..bc013b56 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,10 +1,5 @@ class User < ApplicationRecord - # validates :username, - # format: { with: /\A^[0-9a-z-_]+\Z/, - # message: "Only allows lowercase alphanumeric characters with dashes and underscores", - # allow_blank: true } - before_create :set_encrypted_id def self.from_omniauth(auth_hash) @@ -28,6 +23,6 @@ class User < ApplicationRecord end def set_encrypted_id - self.encrypted_id = Digest::SHA1.hexdigest(uid+provider) + self.encrypted_id = "#{username[0..1]}-#{Digest::SHA1.hexdigest(uid+provider)[0..7]}" end end