Ignore:
Timestamp:
06/26/13 21:17:41 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Improved authentication

  • Authentication cannot be cancelled, removing a lot of weird race conditions.
  • We offer a request provider that has automatic retry in case of authentication failures.
  • Reduced dependency on LoginDialog? by having it act independent based on events. Other modules can just depend on 'session'.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/session.coffee

    r466 r468  
    77    Session = declare [Evented],
    88        info: null
     9
    910        get: () ->
    1011            @info
     12
    1113        restore: () ->
    1214            request '/api/login',
     
    1618                @_set res
    1719            , () =>
    18                 @_set null
     20                throw (@_set null)
     21
    1922        login: (username, password) ->
    2023            request '/api/login',
     
    2730                @_set res
    2831            , () =>
    29                 @_set null
     32                throw (@_set null)
     33
    3034        logout: () ->
    3135            request '/api/logout',
    3236                method: "POST"
    3337                handleAs: "json"
    34             .then ((res) =>
    35                 console.log "Logged out"
    36                 @_set null), () =>
    37                 console.log "Error logging out"
     38            .then (res) =>
     39                @_set null
     40            , () =>
     41                @_set null
    3842       
    3943        _set: (newInfo) ->
    40             @info = newInfo
    41             @emit 'change', @info
    42             @info
     44            if (newInfo isnt @info)
     45                @info = newInfo
     46                @emit 'change', @info
     47                @info
    4348
    4449    new Session()
Note: See TracChangeset for help on using the changeset viewer.