Class: OohAuth::Tokens

Inherits:
Application show all
Defined in:
app/controllers/tokens.rb

Instance Method Summary collapse

Instance Method Details

#create(token) ⇒ Object

Activates an authentication receipt, converting it into a token the authenticating client can use in future requests.

Raises:

  • (NotFound)


50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/tokens.rb', line 50

def create(token)
  only_provides :html
  commit = (params[:commit]=="allow") # Did they click the allow or the deny button? ENQUIRING MINDS NEED TO KNOW!
  raise NotFound unless @token = OohAuth::Token.get_token(request.token) # The oauth_token is now in the post body.
  raise NotFound unless @authenticating_client = @token.authenticating_client # Stop right there, criminal scum.
      
  @activated = @token.activate!(session.user, token[:expires], token[:permissions]) if commit
  redirect("#{request.callback}#{(request.callback["?"])? "&" : "?"}oauth_token=#{@token.token_key}") if commit and request.callback # the callback is in the post body        
  display @token, :create
end

#indexObject

Main action used for starting the authorisation process (desktop clients) and finishing it (web clients)

Raises:

  • (NotAcceptable)


27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/tokens.rb', line 27

def index
  raise NotAcceptable unless @authenticating_client = request.authenticating_client
  if @token = request.authentication_token
    # If client and request key, give the activated token if it was activated.
    raise NotAcceptable unless @token.authenticating_client == @authenticating_client
  else
    # Generate a request key
    @token = OohAuth::Token.create_request_key(@authenticating_client)
  end
  # # Okay, no error raised. Gogo render.
  display @token, :show, :layout=>false
end

#newObject



40
41
42
43
44
45
46
47
# File 'app/controllers/tokens.rb', line 40

def new
  only_provides :html
  unless (@token = OohAuth::Token.first(:token_key=>request.token) and
          @authenticating_client = @token.authenticating_client)
    raise NotAcceptable 
  end
  display @token, :new
end