<commit_before><?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Event;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Events\DelUserEvent;
use App\Acl\Eloquent\Group;

use App\ActiveDirectory\Eloquent\Directory;

use Maatwebsite\Excel\Facades\Excel;
use Cartalyst\Sentinel\Users\EloquentUser;
use Sentinel;
use Activation; 

use App\System\Eloquent\SysSetting;
use App\System\Eloquent\ResetPwdCode;
use Mail;
use Config;

class UserController extends Controller
{
    use ExcelTrait;

    public function __construct()
    {
        $this->middleware('privilege:sys_admin', [ 'except' => [ 'login', 'register', 'getCurrentUser', 'search', 'show', 'sendMailForResetpwd', 'showResetpwd', 'doResetpwd' ] ]);
        parent::__construct();
    }

    /**
     * user login.
     *
     * @return \Illuminate\Http\Response
     */
    public function login(Request $request)
    {
        $email = $request->input('email');
        $password = $request->input('password');
        if (!$email || !$password)
        {
            throw new \UnexpectedValueException('email or password cannot be empty.', -10003);
        }

        if (strpos($email, '@') === false)
        {
            $setting = SysSetting::first();
            if ($setting && isset($setting->properties) && isset($setting->properties['login_mail_domain']))
            {
                $email = $email . '@' . $setting->properties['login_mail_domain'];
            }
        }

        $user = Sentinel::authenticate([ 'email' => $email, 'password' => $password ]);
        if ($user)
        {
            return Response()->json([ 'ecode' => 0, 'data' => $user ]);
        }
        else
        {
            return Response()->json([ 'ecode' => -10000, 'data' => [] ]);
        }
    }

    public function getCurrentUser()
    {
        return Response()->json([ 'ecode' => 0, 'data' => $this->user ]);
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function search(Request $request)
    {
        $s = $request->input('s');
        $users = [];
        if ($s)
        {
            $search_users = EloquentUser::Where('first_name', 'like', '%' . $s .  '%')
                                ->orWhere('email', 'like', '%' . $s .  '%')
                                ->get([ 'first_name', 'last_name', 'email', 'invalid_flag' ]);

            $i = 0;
            foreach ($search_users as $key => $user)
            {
                if ((isset($user->invalid_flag) && $user->invalid_flag === 1) || Activation::completed($user) === false || $user->email === '<EMAIL>')
                {
                    continue;
                }
<commit_msg>delete login for weapp<commit_after><?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Event;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Events\DelUserEvent;
use App\Acl\Eloquent\Group;

use App\ActiveDirectory\Eloquent\Directory;

use Maatwebsite\Excel\Facades\Excel;
use Cartalyst\Sentinel\Users\EloquentUser;
use Sentinel;
use Activation; 

use App\System\Eloquent\SysSetting;
use App\System\Eloquent\ResetPwdCode;
use Mail;
use Config;

class UserController extends Controller
{
    use ExcelTrait;

    public function __construct()
    {
        $this->middleware('privilege:sys_admin', [ 'except' => [ 'login', 'register', 'getCurrentUser', 'search', 'show', 'sendMailForResetpwd', 'showResetpwd', 'doResetpwd' ] ]);
        parent::__construct();
    }

    /**
     * get current user info.
     *
     * @return \Illuminate\Http\Response
     */
    public function getCurrentUser()
    {
        return Response()->json([ 'ecode' => 0, 'data' => $this->user ]);
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function search(Request $request)
    {
        $s = $request->input('s');
        $users = [];
        if ($s)
        {
            $search_users = EloquentUser::Where('first_name', 'like', '%' . $s .  '%')
                                ->orWhere('email', 'like', '%' . $s .  '%')
                                ->get([ 'first_name', 'last_name', 'email', 'invalid_flag' ]);

            $i = 0;
            foreach ($search_users as $key => $user)
            {
                if ((isset($user->invalid_flag) && $user->invalid_flag === 1) || Activation::completed($user) === false || $user->email === '<EMAIL>')
                {
                    continue;
                }

{'fraction_non_alphanumeric': 0.16227312013828868, 'fraction_numerical': 0.003673292999135696, 'mean_word_length': 2.2079002079002077, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 44, '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': '7645267', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1413, 'n_words': 280}