<commit_before>utils = require("./lib/passport_utils")
Adapter = require './lib/adapter'

adapter = new Adapter()
utils = require("./lib/passport_utils")

EMAILREGEX = ///^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|
    (\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|
    (([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$///

handleError = (msg, code, err) ->
    console.log err if err
    send error: true, msg: msg, code

# Update current user data (email and password with given ones)
# Password is encrypted with bcrypt algorithm.
action 'updateAccount', ->

    updateData = (user, body, data, cb) ->

        if body.timezone?
            data.timezone = body.timezone
            #TODO CHECK TIMEZONE VALIDITY

        if body.email? and body.email.length > 0
            if EMAILREGEX.test body.email
                data.email = body.email
            else
                cb null, "Given email is not a proper email"

        if data.timezone or data.email
            user.updateAttributes data, (err) ->
                cb err, null
        else
            cb null

    updatePassword = (user, body, data, cb) ->

        oldPassword = <PASSWORD>
        newPassword = <PASSWORD>
        newPassword2 = <PASSWORD>

<commit_msg>debug: change password user in update account<commit_after>utils = require("./lib/passport_utils")
Adapter = require './lib/adapter'

adapter = new Adapter()
utils = require("./lib/passport_utils")

EMAILREGEX = ///^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|
    (\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|
    (([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$///

handleError = (msg, code, err) ->
    console.log err if err
    send error: true, msg: msg, code

# Update current user data (email and password with given ones)
# Password is encrypted with bcrypt algorithm.
action 'updateAccount', ->

    updateData = (user, body, data, cb) ->

        if body.timezone?
            data.timezone = body.timezone
            #TODO CHECK TIMEZONE VALIDITY

        if body.email? and body.email.length > 0
            if EMAILREGEX.test body.email
                data.email = body.email
            else
                cb null, "Given email is not a proper email"

        if data.timezone or data.email or data.password
            user.updateAttributes data, (err) ->
                cb err, null
        else
            cb null

    updatePassword = (user, body, data, cb) ->

        oldPassword = <PASSWORD>
        newPassword = <PASSWORD>
        newPassword2 = <PASSWORD>


{'fraction_non_alphanumeric': 0.1838091513492374, 'fraction_numerical': 0.016425498631208447, 'mean_word_length': 2.096852300242131, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, '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': '5204419', 'n_tokens_mistral': 872, 'n_tokens_neox': 836, 'n_words': 214}