<commit_before><?php
/**
 * @author      <NAME> <<EMAIL>>
 * @link        https://www.github.com/42php/42php
 * @license     https://opensource.org/licenses/mit-license.html MIT
 * @copyright   2015-2017 42php
 */

use Core\Api,
    Core\Auth,
    Core\Session,
    Core\Site;

/**
 * Class Api_Auth
 */
trait                   Api_Auth {
    public function     auth() {
        Api::post('/session', function() {
            Api::needFields(['email', 'password']);

            $ret = User::login($_REQUEST['email'], $_REQUEST['password']);
            if (!$ret)
                Api::error(403);

            return Session::get('user');
        });

        Api::delete('/session', function() {
            if (!Auth::logged())
                Api::error(403);

            Auth::logout(false);
            Api::code(204);<commit_msg>GET /me api endpoint<commit_after><?php
/**
 * @author      <NAME> <<EMAIL>>
 * @link        https://www.github.com/42php/42php
 * @license     https://opensource.org/licenses/mit-license.html MIT
 * @copyright   2015-2017 42php
 */

use Core\Api,
    Core\Auth,
    Core\Session,
    Core\Site;

/**
 * Class Api_Auth
 */
trait                   Api_Auth {
    public function     auth() {
        Api::get('/me', function() {
            return Session::get('user', false);
        });

        Api::post('/session', function() {
            Api::needFields(['email', 'password']);

            $ret = User::login($_REQUEST['email'], $_REQUEST['password']);
            if (!$ret)
                Api::error(403);

            return Session::get('user');
        });

        Api::delete('/session', function() {
            if (!Auth::logged())
                Api::error(403);

            Auth::logout(false);
            Api::code(204);
{'fraction_non_alphanumeric': 0.17967434025828186, 'fraction_numerical': 0.02582818641212802, 'mean_word_length': 1.864951768488746, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '322416', 'n_tokens_mistral': 549, 'n_tokens_neox': 509, 'n_words': 93}