mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-29 18:46:23 -05:00
24 lines
506 B
Ruby
24 lines
506 B
Ruby
|
class UsernameChanger
|
||
|
|
||
|
def initialize(user, new_username, actor=nil)
|
||
|
@user = user
|
||
|
@new_username = new_username
|
||
|
@actor = actor
|
||
|
end
|
||
|
|
||
|
def self.change(user, new_username, actor=nil)
|
||
|
self.new(user, new_username, actor).change
|
||
|
end
|
||
|
|
||
|
def change
|
||
|
if @actor && @actor != @user
|
||
|
StaffActionLogger.new(@actor).log_username_change(@user, @user.username, @new_username)
|
||
|
end
|
||
|
|
||
|
# future work: update mentions and quotes
|
||
|
|
||
|
@user.username = @new_username
|
||
|
@user.save
|
||
|
end
|
||
|
end
|