<commit_before>ReduxRouter = require 'redux-simple-router'

API = require 'api'
utils = require '../utils.coffee'
URL = require '../url.coffee'
appActions = require './app-actions.coffee'

module.exports =
	sessionTimeout: ->
		type: 'SESSION_TIMEOUT'
	login: (data) ->
		type: 'LOGIN'
		payload:
			promise: API.login(data).then (body) ->
				(action, dispatch) ->
					params = JSON.parse data.from
					params.userId = utils.getUserId body.user._id
					dispatch ReduxRouter.pushPath URL.getPath(params), params
					action.payload = body
					dispatch action
	logout: (data) ->
		type: 'LOGOUT'
		payload:
			promise: API.logout(data.id).then ->
				(action, dispatch) ->
					dispatch ReduxRouter.pushPath data.from
					dispatch action
	setUser: (obj, timestamp) ->
		type: 'SET_LOGGEDIN_USER'
		payload:
			user: obj.user || obj || null
			authenticationTime: obj.timestamp || timestamp
	signup: (data) ->
		type: 'SIGNUP'
		payload:
			promise: API.signup data<commit_msg>Use params also when logging out.<commit_after>ReduxRouter = require 'redux-simple-router'

API = require 'api'
utils = require '../utils.coffee'
URL = require '../url.coffee'
appActions = require './app-actions.coffee'

module.exports =
	sessionTimeout: ->
		type: 'SESSION_TIMEOUT'
	login: (data) ->
		type: 'LOGIN'
		payload:
			promise: API.login(data).then (body) ->
				(action, dispatch) ->
					params = JSON.parse data.from
					params.userId = utils.getUserId body.user._id
					dispatch ReduxRouter.pushPath URL.getPath(params), params
					action.payload = body
					dispatch action
	logout: (data) ->
		type: 'LOGOUT'
		payload:
			promise: API.logout(data.id).then ->
				(action, dispatch) ->
					params = JSON.parse data.from
					delete params.userId
					dispatch ReduxRouter.pushPath URL.getPath(params), params
					dispatch action
	setUser: (obj, timestamp) ->
		type: 'SET_LOGGEDIN_USER'
		payload:
			user: obj.user || obj || null
			authenticationTime: obj.timestamp || timestamp
	signup: (data) ->
		type: 'SIGNUP'
		payload:
			promise: API.signup data
{'fraction_non_alphanumeric': 0.1330743079164643, 'fraction_numerical': 0.0, 'mean_word_length': 3.336842105263158, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5311377', 'n_tokens_mistral': 793, 'n_tokens_neox': 683, 'n_words': 166}