Skip to content

Instantly share code, notes, and snippets.

@mkrogh
Created November 1, 2012 19:48
Show Gist options
  • Save mkrogh/3995995 to your computer and use it in GitHub Desktop.
Save mkrogh/3995995 to your computer and use it in GitHub Desktop.
def create
@admin = Admin.find_by_provider_and_uid(auth["provider"], auth["uid"])
if @admin and @admin.approved
session[:user_id] = @admin.id
flash[:success] = "Hej #{@admin.name} du er nu logget ind"
redirect_to session[:return_to] || manage_golds_path
else
unless @admin.present?
new_admin = Admin.create(:name => auth["info"]["name"], :provider => auth["provider"], :uid => auth["uid"])
BankAccountMailer.admin_created(new_admin).deliver
end
flash[:error] = "Beklager #{auth["info"]["name"]} du har ikke adgang til systemet."
redirect_to root_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment