summaryrefslogtreecommitdiff
path: root/app/controllers/v1/smtp_certs_controller.rb
blob: 258b39147db2a3650a34bfce30a9490369918dd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class V1::SmtpCertsController < ApplicationController

  before_filter :require_login
  before_filter :require_email_account

  # GET /cert
  def show
    @cert = ClientCertificate.new prefix: current_user.email_address
    current_user.identity.cert_fingerprints << @cert.fingerprint
    current_user.identity.save
    render text: @cert.to_s, content_type: 'text/plain'
  end

  protected

  def require_email_account
    access_denied unless service_level.provides? 'email'
  end

  def service_level
    current_user.effective_service_level
  end
end