diff options
author | Azul <azul@leap.se> | 2014-06-09 11:00:28 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-06-09 11:00:28 +0200 |
commit | 728d6d3985126c2890638bb2ee24020fa0e36a80 (patch) | |
tree | 1fcbb560b0103123d49fb953e86fdb960ee5dd13 /app/controllers/v1/smtp_certs_controller.rb | |
parent | b9174fdc9d9bd403d9a16650bafc4715e3dbf2d4 (diff) | |
parent | 9fa52ed80d71ec56ed5acf18dfd63bd03b201cc5 (diff) |
Merge tag '0.5.2'
Diffstat (limited to 'app/controllers/v1/smtp_certs_controller.rb')
-rw-r--r-- | app/controllers/v1/smtp_certs_controller.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/controllers/v1/smtp_certs_controller.rb b/app/controllers/v1/smtp_certs_controller.rb new file mode 100644 index 0000000..377a49c --- /dev/null +++ b/app/controllers/v1/smtp_certs_controller.rb @@ -0,0 +1,37 @@ +class V1::SmtpCertsController < ApplicationController + + before_filter :require_login + before_filter :require_email_account + before_filter :fetch_identity + + # POST /1/smtp_cert + def create + @cert = ClientCertificate.new prefix: current_user.email_address + @identity.register_cert(@cert) + @identity.save + render text: @cert.to_s, content_type: 'text/plain' + end + + protected + + # + # Filters + # + + def require_email_account + access_denied unless service_level.provides? 'email' + end + + def fetch_identity + @identity = current_user.identity + end + + # + # Helper methods + # + + def service_level + current_user.effective_service_level + end + +end |