mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-30 20:51:23 -04:00
81 lines
2.1 KiB
Ruby
81 lines
2.1 KiB
Ruby
class AuthenticationsController < ApplicationController
|
|
# GET /authentications
|
|
# GET /authentications.json
|
|
def index
|
|
@authentications = Authentication.all
|
|
|
|
respond_to do |format|
|
|
format.html # index.html.erb
|
|
format.json { render json: @authentications }
|
|
end
|
|
end
|
|
|
|
# GET /authentications/1
|
|
# GET /authentications/1.json
|
|
def show
|
|
@authentication = Authentication.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
format.html # show.html.erb
|
|
format.json { render json: @authentication }
|
|
end
|
|
end
|
|
|
|
# GET /authentications/new
|
|
# GET /authentications/new.json
|
|
def new
|
|
@authentication = Authentication.new
|
|
|
|
respond_to do |format|
|
|
format.html # new.html.erb
|
|
format.json { render json: @authentication }
|
|
end
|
|
end
|
|
|
|
# GET /authentications/1/edit
|
|
def edit
|
|
@authentication = Authentication.find(params[:id])
|
|
end
|
|
|
|
# POST /authentications
|
|
# POST /authentications.json
|
|
def create
|
|
auth = request.env['omniauth.auth']
|
|
current_member.authentications.create(
|
|
:provider => auth['provider'],
|
|
:uid => auth['uid'],
|
|
:token => auth['credentials']['token'],
|
|
:secret => auth['credentials']['secret'])
|
|
flash[:notice] = "Authentication successful."
|
|
redirect_to authentications_url
|
|
end
|
|
|
|
# PUT /authentications/1
|
|
# PUT /authentications/1.json
|
|
def update
|
|
@authentication = Authentication.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
if @authentication.update_attributes(params[:authentication])
|
|
format.html { redirect_to @authentication, notice: 'Authentication was successfully updated.' }
|
|
format.json { head :no_content }
|
|
else
|
|
format.html { render action: "edit" }
|
|
format.json { render json: @authentication.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /authentications/1
|
|
# DELETE /authentications/1.json
|
|
def destroy
|
|
@authentication = Authentication.find(params[:id])
|
|
@authentication.destroy
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to authentications_url }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
end
|