Sha256: be0094775a533f4b4883ad1f2ebb25b254828cac0fb7446c9a5c315a7697f46d

Contents?: true

Size: 952 Bytes

Versions: 3

Compression:

Stored size: 952 Bytes

Contents

module Lanes
    module API

        Root.get '/' do
            content_type 'text/html'
            erb :index
        end

        Root.get "default-records" do
            { success: true, data: Lanes::API.default_records }
        end

        Root.post "/user-session.json" do
            wrap_json_reply do
                user = User.where(login: data['login']).first
                if user && user.authenticate(data['password'])
                    session[:user_id] = user.id
                    { success: true, message: "Login succeeded", data: user.workspace_data }
                else
                    { success: false, message: "Login failed", errors: { login: 'failed' }, data: {} }
                end
            end
        end

        Root.delete "/user-session.json" do
            session.destroy
            { success: true, message: "Logout succeeded", data: {} }
        end

        Root.build_route User



    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lanes-0.0.3 lib/lanes/api/default_routes.rb
lanes-0.0.2 lib/lanes/api/default_routes.rb
lanes-0.0.1 lib/lanes/api/default_routes.rb