首页 > 解决方案 > 如何在 URL 中隐藏密码

问题描述

我不知道 url 上的隐藏密码是如何遇到这样的问题http://127.0.0.1:8000/bulletin/%201/edit?passwordC=11111&page=1

我的观点

<form>
                        <div class="form-row" style="specified-width:200; position: absolute; bottom:0; margin-bottom:10">
                            <input style="width:150px" type="password"  placeholder="Password" name="passwordC">
                            <input type="hidden"  value="{{$buletin->currentPage()}}" name="page">
                            <button style="margin:0 5px" formAction="/bulletin/ {{ $tampil_B->id }}/deleteOper" type="submit" class="btn btn-danger">Delete</button>
                            <button formAction='(url(edit))' type="submit" class="btn btn-primary">Edit</button>
                        </div>
                    </form>

我的路由器

route::get('/bulletin/{id}/edit','BulletinController@edit');

我的控制器

  public function edit (Request $request, $id)
{
    $buletin = \App\Dashboard::find($id);
    $url = "/?page={$request->page}";



    if(is_null($buletin->password)){

        $request->session()->flash('failed', 'Cant Edit Because this post not had been set  password ');
        return view('bulletin.edit_nopass', ['buletin' => $buletin,'url'=> $url]);

    }

    if (hash::check($request->passwordC,$buletin->password)){
        return view ('bulletin.edit', ['buletin' => $buletin, 'url'=> $url]);//save and go back to card

        } else {

            $request->validate([
                'passwordC' => 'required|required_with:password|same:password'
                ],[
                'passwordC.required_with' => "Password not match",
                'passwordC.required' => "Password Required",
                'passwordC.same' => "The Password You Entered Do Not Match.Please Try Again"
                    ]);
                }

标签: laravelfunctionviewcontrollerrouting

解决方案


首先,用 . 发送是不正确的GET。但如果它非常重要,你有两种方法:

1.使用。encrypt但它也不安全。因为甚至有可以解密的在线网站。2.使用Hash:make。散列是单方面的。这意味着你不能对它进行散列


推荐阅读