Sha256: b97a99be67cdad926c1a37ebbef5d04a77a665d4bc8b568b52d79aefe8b4038e

Contents?: true

Size: 1014 Bytes

Versions: 4

Compression:

Stored size: 1014 Bytes

Contents

class Session
  include ActiveModel::Serializers::JSON
  include ActiveModel::Serializers::Xml

  attr_accessor :permissions, :user

  def self.create(params = {})
    if Rails.application.config.respond_to? :remote_sso_url
      begin
        a = Authentication.create(:login => params[:login],
                                  :password => params[:password])
        result = new
        user = User.new
        user.login = a.login
        user.name = a.name
        user.groups = a.groups
        result.user = user
        result
      rescue ActiveResource::ResourceNotFound
        nil
      end
    else
      user = User.authenticate(params[:login], params[:password])
      if user
        result = new
        result.user = user
        result
      end
    end
  end

  def idle_session_timeout
    Rails.application.config.idle_session_timeout
  end

  def attributes
    {'idle_session_timeout' => idle_session_timeout, 'permissions' => permissions, 'user' => user}
  end

  def id
    ""
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
resty-generators-0.5.3 lib/generators/resty/setup/templates/session.rb
resty-generators-0.5.1 lib/generators/resty/setup/templates/session.rb
resty-generators-0.5.0 lib/generators/resty/setup/templates/session.rb
resty-generators-0.4.0 lib/generators/resty/setup/templates/session.rb