mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Correct annotations
allow longer usernames (up to 60)
This commit is contained in:
parent
86985e345e
commit
862a6696c0
41 changed files with 117 additions and 108 deletions
|
@ -29,8 +29,8 @@ end
|
|||
# key :string(64) not null
|
||||
# user_id :integer
|
||||
# created_by_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -334,8 +334,8 @@ end
|
|||
# color :string(6) default("AB9364"), not null
|
||||
# topic_id :integer
|
||||
# topic_count :integer default(0), not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :integer not null
|
||||
# topics_year :integer default(0)
|
||||
# topics_month :integer default(0)
|
||||
|
@ -360,7 +360,7 @@ end
|
|||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_categories_on_email_in (email_in) UNIQUE
|
||||
# index_categories_on_name (name) UNIQUE
|
||||
# index_categories_on_topic_count (topic_count)
|
||||
# index_categories_on_email_in (email_in) UNIQUE
|
||||
# index_categories_on_forum_thread_count (topic_count)
|
||||
# index_categories_on_name (name) UNIQUE
|
||||
#
|
||||
|
|
|
@ -52,8 +52,8 @@ end
|
|||
#
|
||||
# category_id :integer not null
|
||||
# topic_id :integer not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# rank :integer default(0), not null
|
||||
# id :integer not null, primary key
|
||||
#
|
||||
|
|
|
@ -53,8 +53,8 @@ end
|
|||
# id :integer not null, primary key
|
||||
# category_id :integer
|
||||
# user_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -15,7 +15,7 @@ end
|
|||
# id :integer not null, primary key
|
||||
# category_id :integer not null
|
||||
# group_id :integer not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# permission_type :integer default(1)
|
||||
#
|
||||
|
|
|
@ -41,14 +41,14 @@ class DiscourseSingleSignOn < SingleSignOn
|
|||
|
||||
def lookup_or_create_user
|
||||
sso_record = SingleSignOnRecord.where(external_id: external_id).first
|
||||
|
||||
|
||||
if sso_record && user = sso_record.user
|
||||
sso_record.last_payload = unsigned_payload
|
||||
else
|
||||
user = match_email_or_create_user
|
||||
sso_record = user.single_sign_on_record
|
||||
end
|
||||
|
||||
|
||||
# if the user isn't new or it's attached to the SSO record we might be overriding username or email
|
||||
unless user.new_record?
|
||||
change_external_attributes_and_override(sso_record, user)
|
||||
|
@ -59,16 +59,16 @@ class DiscourseSingleSignOn < SingleSignOn
|
|||
user.save
|
||||
user.enqueue_welcome_message('welcome_user')
|
||||
end
|
||||
|
||||
|
||||
# optionally save the user and sso_record if they have changed
|
||||
user.save!
|
||||
sso_record.save!
|
||||
|
||||
sso_record && sso_record.user
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def match_email_or_create_user
|
||||
user = User.where(email: Email.downcase(email)).first
|
||||
|
||||
|
@ -90,31 +90,31 @@ class DiscourseSingleSignOn < SingleSignOn
|
|||
external_name: name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
user
|
||||
end
|
||||
|
||||
|
||||
def change_external_attributes_and_override(sso_record, user)
|
||||
if SiteSetting.sso_overrides_email && email != sso_record.external_email
|
||||
# set the user's email to whatever came in the payload
|
||||
user.email = email
|
||||
end
|
||||
|
||||
|
||||
if SiteSetting.sso_overrides_username && username != sso_record.external_username && user.username != username
|
||||
# we have an external username change, and the user's current username doesn't match
|
||||
# run it through the UserNameSuggester to override it
|
||||
user.username = UserNameSuggester.suggest(username || name || email)
|
||||
user.username = UserNameSuggester.suggest(username || name || email)
|
||||
end
|
||||
|
||||
|
||||
if SiteSetting.sso_overrides_name && name != sso_record.external_name && user.name != name
|
||||
# we have an external name change, and the user's current name doesn't match
|
||||
# run it through the name suggester to override it
|
||||
user.name = User.suggest_name(name || username || email)
|
||||
end
|
||||
|
||||
|
||||
# change external attributes for sso record
|
||||
sso_record.external_username = username
|
||||
sso_record.external_email = email
|
||||
sso_record.external_name = name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,8 +46,8 @@ end
|
|||
# user_id :integer not null
|
||||
# draft_key :string(255) not null
|
||||
# data :text not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# sequence :integer default(0), not null
|
||||
#
|
||||
# Indexes
|
||||
|
|
|
@ -37,8 +37,8 @@ end
|
|||
# to_address :string(255) not null
|
||||
# email_type :string(255) not null
|
||||
# user_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# reply_key :string(32)
|
||||
# post_id :integer
|
||||
# topic_id :integer
|
||||
|
|
|
@ -73,8 +73,8 @@ end
|
|||
# token :string(255) not null
|
||||
# confirmed :boolean default(FALSE), not null
|
||||
# expired :boolean default(FALSE), not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -16,8 +16,8 @@ end
|
|||
# gender :string(255)
|
||||
# name :string(255)
|
||||
# link :string(255)
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -10,8 +10,8 @@ end
|
|||
# user_id :integer not null
|
||||
# screen_name :string(255) not null
|
||||
# github_user_id :integer not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -235,8 +235,8 @@ end
|
|||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# automatic :boolean default(FALSE), not null
|
||||
# user_count :integer default(0), not null
|
||||
# alias_level :integer default(0)
|
||||
|
|
|
@ -10,8 +10,8 @@ end
|
|||
# id :integer not null, primary key
|
||||
# group_id :integer not null
|
||||
# user_id :integer not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -104,8 +104,8 @@ end
|
|||
# domain :string(100)
|
||||
# topic_id :integer
|
||||
# post_number :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :integer
|
||||
# ip_address :inet
|
||||
# current_user_id :integer
|
||||
|
|
|
@ -127,8 +127,8 @@ end
|
|||
# invited_by_id :integer not null
|
||||
# user_id :integer
|
||||
# redeemed_at :datetime
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# deleted_at :datetime
|
||||
# deleted_by_id :integer
|
||||
# invalidated_at :datetime
|
||||
|
|
|
@ -142,8 +142,8 @@ end
|
|||
# user_id :integer not null
|
||||
# data :string(1000) not null
|
||||
# read :boolean default(FALSE), not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# topic_id :integer
|
||||
# post_number :integer
|
||||
# post_action_id :integer
|
||||
|
|
|
@ -13,8 +13,8 @@ end
|
|||
# provider :string(255) not null
|
||||
# email :string(255)
|
||||
# name :string(255)
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -513,8 +513,8 @@ end
|
|||
# post_number :integer not null
|
||||
# raw :text not null
|
||||
# cooked :text not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# reply_to_post_number :integer
|
||||
# reply_count :integer default(0), not null
|
||||
# quote_count :integer default(0), not null
|
||||
|
@ -553,5 +553,5 @@ end
|
|||
# idx_posts_created_at_topic_id (created_at,topic_id)
|
||||
# idx_posts_user_id_deleted_at (user_id)
|
||||
# index_posts_on_reply_to_post_number (reply_to_post_number)
|
||||
# index_posts_on_topic_id_and_post_number (topic_id,post_number)
|
||||
# index_posts_on_topic_id_and_post_number (topic_id,post_number) UNIQUE
|
||||
#
|
||||
|
|
|
@ -335,8 +335,8 @@ end
|
|||
# user_id :integer not null
|
||||
# post_action_type_id :integer not null
|
||||
# deleted_at :datetime
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# deleted_by_id :integer
|
||||
# message :text
|
||||
# related_post_id :integer
|
||||
|
|
|
@ -45,8 +45,8 @@ end
|
|||
# name_key :string(50) not null
|
||||
# is_flag :boolean default(FALSE), not null
|
||||
# icon :string(20)
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# id :integer not null, primary key
|
||||
# position :integer default(0), not null
|
||||
#
|
||||
|
|
|
@ -14,8 +14,8 @@ end
|
|||
# key :string(255)
|
||||
# value :string(255)
|
||||
# extra :text
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -11,8 +11,8 @@ end
|
|||
#
|
||||
# post_id :integer
|
||||
# reply_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -33,12 +33,12 @@ end
|
|||
# action_type :integer not null
|
||||
# match_count :integer default(0), not null
|
||||
# last_match_at :datetime
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# ip_address :inet
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_screened_emails_on_email (email) UNIQUE
|
||||
# index_screened_emails_on_last_match_at (last_match_at)
|
||||
# index_blocked_emails_on_email (email) UNIQUE
|
||||
# index_blocked_emails_on_last_match_at (last_match_at)
|
||||
#
|
||||
|
|
|
@ -92,8 +92,8 @@ end
|
|||
# action_type :integer not null
|
||||
# match_count :integer default(0), not null
|
||||
# last_match_at :datetime
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -47,8 +47,8 @@ end
|
|||
# action_type :integer not null
|
||||
# match_count :integer default(0), not null
|
||||
# last_match_at :datetime
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# ip_address :inet
|
||||
#
|
||||
# Indexes
|
||||
|
|
|
@ -37,8 +37,8 @@ end
|
|||
#
|
||||
# content_type :string(255) not null, primary key
|
||||
# content :text not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -230,8 +230,8 @@ end
|
|||
# user_id :integer not null
|
||||
# enabled :boolean not null
|
||||
# key :string(255) not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# override_default_style :boolean default(FALSE), not null
|
||||
# stylesheet_baked :text default(""), not null
|
||||
# mobile_stylesheet :text
|
||||
|
|
|
@ -93,6 +93,6 @@ end
|
|||
# name :string(255) not null
|
||||
# data_type :integer not null
|
||||
# value :text
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
|
|
@ -754,8 +754,8 @@ end
|
|||
# id :integer not null, primary key
|
||||
# title :string(255) not null
|
||||
# last_posted_at :datetime
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# views :integer default(0), not null
|
||||
# posts_count :integer default(0), not null
|
||||
# user_id :integer
|
||||
|
@ -807,6 +807,6 @@ end
|
|||
#
|
||||
# idx_topics_front_page (deleted_at,visible,archetype,category_id,id)
|
||||
# idx_topics_user_id_deleted_at (user_id)
|
||||
# index_topics_on_bumped_at (bumped_at)
|
||||
# index_forum_threads_on_bumped_at (bumped_at)
|
||||
# index_topics_on_id_and_deleted_at (id,deleted_at)
|
||||
#
|
||||
|
|
|
@ -12,8 +12,8 @@ end
|
|||
# id :integer not null, primary key
|
||||
# user_id :integer not null
|
||||
# topic_id :integer not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -15,8 +15,8 @@ end
|
|||
# id :integer not null, primary key
|
||||
# topic_id :integer not null
|
||||
# invite_id :integer not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -208,8 +208,8 @@ end
|
|||
# domain :string(100) not null
|
||||
# internal :boolean default(FALSE), not null
|
||||
# link_topic_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# reflection :boolean default(FALSE)
|
||||
# clicks :integer default(0), not null
|
||||
# link_post_id :integer
|
||||
|
@ -218,6 +218,6 @@ end
|
|||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_topic_links_on_topic_id (topic_id)
|
||||
# unique_post_links (topic_id,post_id,url) UNIQUE
|
||||
# index_forum_thread_links_on_forum_thread_id (topic_id)
|
||||
# index_forum_thread_links_on_forum_thread_id_and_post_id_and_url (topic_id,post_id,url) UNIQUE
|
||||
#
|
||||
|
|
|
@ -58,11 +58,11 @@ end
|
|||
# id :integer not null, primary key
|
||||
# topic_link_id :integer not null
|
||||
# user_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# ip_address :inet not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# by_link (topic_link_id)
|
||||
# index_forum_thread_link_clicks_on_forum_thread_link_id (topic_link_id)
|
||||
#
|
||||
|
|
|
@ -279,5 +279,5 @@ end
|
|||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_topic_users_on_topic_id_and_user_id (topic_id,user_id) UNIQUE
|
||||
# index_forum_thread_users_on_forum_thread_id_and_user_id (topic_id,user_id) UNIQUE
|
||||
#
|
||||
|
|
|
@ -10,8 +10,8 @@ end
|
|||
# user_id :integer not null
|
||||
# screen_name :string(255) not null
|
||||
# twitter_user_id :integer not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -125,8 +125,8 @@ end
|
|||
# width :integer
|
||||
# height :integer
|
||||
# url :string(255) not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# sha1 :string(40)
|
||||
# origin :string(1000)
|
||||
#
|
||||
|
|
|
@ -692,9 +692,9 @@ end
|
|||
# Table name: users
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# username :string(20) not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# username :string(60) not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# name :string(255)
|
||||
# bio_raw :text
|
||||
# seen_notification_id :integer default(0), not null
|
||||
|
@ -703,7 +703,7 @@ end
|
|||
# password_hash :string(64)
|
||||
# salt :string(32)
|
||||
# active :boolean
|
||||
# username_lower :string(20) not null
|
||||
# username_lower :string(60) not null
|
||||
# auth_token :string(32)
|
||||
# last_seen_at :datetime
|
||||
# website :string(255)
|
||||
|
@ -738,8 +738,8 @@ end
|
|||
# uploaded_avatar_id :integer
|
||||
# email_always :boolean default(FALSE), not null
|
||||
# mailing_list_mode :boolean default(FALSE), not null
|
||||
# locale :string(10)
|
||||
# primary_group_id :integer
|
||||
# locale :string(10)
|
||||
# profile_background :string(255)
|
||||
#
|
||||
# Indexes
|
||||
|
|
|
@ -313,12 +313,12 @@ end
|
|||
# target_post_id :integer
|
||||
# target_user_id :integer
|
||||
# acting_user_id :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# idx_unique_rows (action_type,user_id,target_topic_id,target_post_id,acting_user_id) UNIQUE
|
||||
# index_user_actions_on_acting_user_id (acting_user_id)
|
||||
# index_user_actions_on_user_id_and_action_type (user_id,action_type)
|
||||
# idx_unique_rows (action_type,user_id,target_topic_id,target_post_id,acting_user_id) UNIQUE
|
||||
# index_actions_on_acting_user_id (acting_user_id)
|
||||
# index_actions_on_user_id_and_action_type (user_id,action_type)
|
||||
#
|
||||
|
|
|
@ -104,8 +104,8 @@ end
|
|||
# acting_user_id :integer
|
||||
# target_user_id :integer
|
||||
# details :text
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# context :string(255)
|
||||
# ip_address :string(255)
|
||||
# email :string(255)
|
||||
|
@ -117,8 +117,8 @@ end
|
|||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_staff_action_logs_on_action_and_id (action,id)
|
||||
# index_staff_action_logs_on_subject_and_id (subject,id)
|
||||
# index_staff_action_logs_on_target_user_id_and_id (target_user_id,id)
|
||||
# index_user_histories_on_acting_user_id_and_action_and_id (acting_user_id,action,id)
|
||||
# index_user_histories_on_action_and_id (action,id)
|
||||
# index_user_histories_on_subject_and_id (subject,id)
|
||||
# index_user_histories_on_target_user_id_and_id (target_user_id,id)
|
||||
#
|
||||
|
|
|
@ -13,8 +13,8 @@ end
|
|||
# user_id :integer not null
|
||||
# email :string(255) not null
|
||||
# url :string(255) not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# active :boolean not null
|
||||
#
|
||||
# Indexes
|
||||
|
|
9
db/migrate/20140415054717_allow_longer_usernames.rb
Normal file
9
db/migrate/20140415054717_allow_longer_usernames.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class AllowLongerUsernames < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :users, :username, :string, limit: 60
|
||||
change_column :users, :username_lower, :string, limit: 60
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue