2013-02-05 14:16:51 -05:00
|
|
|
class EmailController < ApplicationController
|
|
|
|
skip_before_filter :check_xhr
|
|
|
|
layout 'no_js'
|
|
|
|
|
|
|
|
before_filter :ensure_logged_in, only: :preferences_redirect
|
|
|
|
|
|
|
|
def preferences_redirect
|
|
|
|
redirect_to(email_preferences_path(current_user.username_lower))
|
|
|
|
end
|
|
|
|
|
|
|
|
def unsubscribe
|
2013-02-07 10:45:24 -05:00
|
|
|
@user = User.find_by_temporary_key(params[:key])
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
# Don't allow the use of a key while logged in as a different user
|
2013-03-04 19:42:44 -05:00
|
|
|
@user = nil if current_user.present? && (@user != current_user)
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
if @user.present?
|
|
|
|
@user.update_column(:email_digests, false)
|
|
|
|
else
|
|
|
|
@not_found = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def resubscribe
|
|
|
|
@user = User.find_by_temporary_key(params[:key])
|
|
|
|
raise Discourse::NotFound unless @user.present?
|
|
|
|
@user.update_column(:email_digests, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|