From b8c862c43b29b3cb8f26e213097ce986abce7271 Mon Sep 17 00:00:00 2001 From: Futseh Date: Fri, 1 Mar 2019 18:23:27 +0100 Subject: Removed the regex validation for discord name --- app/helpers/users_helper.rb | 1 - app/models/user.rb | 3 +-- app/views/users/show.html.erb | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 7ad99d8..73704ed 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -51,5 +51,4 @@ module UsersHelper return nil end end - end diff --git a/app/models/user.rb b/app/models/user.rb index 85c154e..a34dcf7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,11 +18,10 @@ class User < ActiveRecord::Base validates_length_of :name, in: 2..30 validates_length_of :about, maximum: 5000 validates_length_of :ign, minimum: 1, maximum: 16 - validates_length_of :discord, minimum: 2, maximum: 37 # The maximum length of a name is 32, but you need the # and four numbers + validates_length_of :discord, minimum: 7, maximum: 37 # The maximum length of a name is 32, but you need the # and four numbers validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[(IPv6)?[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."} validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."} - validates :discord, uniqueness: {case_sensitive: false}, format: {with: /\A^(?!everyone|here|discordtag|.*```.*)([^@#:]{2,32}#[0-9]{4})$\z/i, message: "Discord name is invalid."} validates :public_key, format: {with: /\A(-----BEGIN PGP PUBLIC KEY BLOCK-----((.|\n)*?)-----END PGP PUBLIC KEY BLOCK-----)?\z/i, message: "That doesn't look like a PGP formatted public key."} diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 1edf6db..9853b08 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -82,6 +82,16 @@ Joined <%= ago @user.created_at %> + + Last seen + + <% if @user.last_seen %> + <%= ago @user.last_seen %> + <% else %> + Never + <% end %> + + <% if mod? || @user.is?(current_user) %> Last IP @@ -91,16 +101,6 @@ Email <%= mail_to @user.email, @user.email, :subject => "Redstoner" %> - - Last seen - - <% if @user.last_seen %> - <%= ago @user.last_seen %> - <% else %> - Never - <% end %> - - <% end %> -- cgit v1.2.3 From 52659dd446ae2628927da520393ec6c8a839bc74 Mon Sep 17 00:00:00 2001 From: Futseh Date: Fri, 1 Mar 2019 18:47:45 +0100 Subject: You can now update a profile even if the discord field is empty --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index a34dcf7..b3bc033 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,10 +18,10 @@ class User < ActiveRecord::Base validates_length_of :name, in: 2..30 validates_length_of :about, maximum: 5000 validates_length_of :ign, minimum: 1, maximum: 16 - validates_length_of :discord, minimum: 7, maximum: 37 # The maximum length of a name is 32, but you need the # and four numbers validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[(IPv6)?[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."} validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."} + validates :discord, uniqueness: {case_sensitive: false}, format: {with: /\A^(?!everyone|here|discordtag|.*```.*)([^@#:]{2,32}#[0-9]{4})$\z/i, message: "Discord name is invalid."}, allow_blank: true validates :public_key, format: {with: /\A(-----BEGIN PGP PUBLIC KEY BLOCK-----((.|\n)*?)-----END PGP PUBLIC KEY BLOCK-----)?\z/i, message: "That doesn't look like a PGP formatted public key."} -- cgit v1.2.3