<commit_before>'use strict'

passport = require 'koa-passport'
{Strategy} = require 'passport-local'

i18n = require '../core/i18n'
user = new User = require '../model/User'

NotFoundException = require '../core/errors/NotFound'
ForbiddenException = require '../core/errors/Forbidden'

passport.serializeUser (iUserId, cb) -> cb null, iUserId
passport.deserializeUser user.getAuthenticated

passport.use new Strategy
  usernameField: 'username'
  passwordField: '<PASSWORD>',
  user.auth

# tmp
mailer = require '../core/mail/mailer'

###
# Response signin page
# 
# GET /auth/signin
###
actionLogin = (next) ->
  if do @isAuthenticated
    return @redirect '/'

  @render 'auth/signin',
    title: i18n.t 'user.title.signin'
    __csrf: @csrf
    __return: @query.return or '/'

  yield next

###
# POST /auth/signin
###<commit_msg>Small fix for auth controller<commit_after>'use strict'

passport = require 'koa-passport'
{Strategy} = require 'passport-local'

i18n = require '../core/i18n'
user = new User = require '../model/User'

NotFoundException = require '../core/errors/NotFound'
ForbiddenException = require '../core/errors/Forbidden'

passport.serializeUser (iUserId, cb) -> cb null, iUserId
passport.deserializeUser user.getAuthenticated

passport.use new Strategy
  usernameField: 'username'
  passwordField: '<PASSWORD>',
  user.auth

###
# Response signin page
# 
# GET /auth/signin
###
actionLogin = (next) ->
  if do @isAuthenticated
    return @redirect '/'

  @render 'auth/signin',
    title: i18n.t 'user.title.signin'
    __csrf: @csrf
    __return: @query.return or '/'

  yield next

###
# POST /auth/signin
###
{'fraction_non_alphanumeric': 0.1460880195599022, 'fraction_numerical': 0.007334963325183374, 'mean_word_length': 3.8865671641791044, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6407808', 'n_tokens_mistral': 558, 'n_tokens_neox': 555, 'n_words': 136}