<?php

namespace App\Http\Controllers\api\thirdPart\weixin;

use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;

class WxLoginController extends Controller
{
    public function login(Request $request){
        $name = $request->input('name');
        $pwd = $request->input('password');
        $user = User::where('name', $name)->first();
        if ($user){
            $isRight=Hash::check($pwd,$user['password']);
            if ($isRight){
                app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),$user->id);
                return ['api_token'=>$user->token()];
            }
            else return ['api_token'=>''];
        }
        return ['api_token'=>''];
    }
}
