discourse/app/controllers/email_controller.rb

37 lines
917 B
Ruby
Raw Normal View History

2013-02-06 03:16:51 +08:00
class EmailController < ApplicationController
skip_before_filter :check_xhr, :preload_json
layout 'no_ember'
2013-02-06 03:16:51 +08:00
before_filter :ensure_logged_in, only: :preferences_redirect
skip_before_filter :redirect_to_login_if_required
2013-02-06 03:16:51 +08:00
def preferences_redirect
redirect_to(email_preferences_path(current_user.username_lower))
end
def unsubscribe
@user = DigestUnsubscribeKey.user_for_key(params[:key])
2013-02-06 03:16:51 +08:00
# Don't allow the use of a key while logged in as a different user
if current_user.present? && (@user != current_user)
@different_user = true
return
end
2013-02-06 03:16:51 +08:00
if @user.blank?
2013-02-06 03:16:51 +08:00
@not_found = true
return
2013-02-06 03:16:51 +08:00
end
@user.update_column(:email_digests, false)
@success = true
2013-02-06 03:16:51 +08:00
end
def resubscribe
@user = DigestUnsubscribeKey.user_for_key(params[:key])
2013-02-06 03:16:51 +08:00
raise Discourse::NotFound unless @user.present?
@user.update_column(:email_digests, true)
end
end