小编Kre*_*nor的帖子

Laravel 5:按用户组限制对控制器的访问

我已经开始学习 Laravel 5.1,到目前为止我很喜欢它!但有一件事我还没有明白。
在我之前的项目中,我有 2 个特定的控制器(例如:“正常”、“扩展”),在成功登录后,它们根据user_group数据库中的用户被调用。

如果“Foo.Bar”输入了他的有效凭据并拥有normal他被重定向到的组NormalControler。由于我没有使用任何框架,因此我通过为组设置 a$_SESSION并检查它来限制对另一个组的访问。因此,如果另一个组试图访问该控制器,他就会被重定向。

这在 Laravel 5 中如何实现?到目前为止,我有一个无需身份验证即可调用的控制器,并且受以下代码限制routes.php

// All routes in the group are protected, only authed user are allowed to access them
Route::group(array('before' => 'auth'), function() {

    // TO-DO : Seperate Controller access
});
Run Code Online (Sandbox Code Playgroud)

登录看起来像这样:

public function performLogin()
    {   

        $logindata = array(
            'username' => Input::get('user_name'),
            'password' => Input::get('user_pass')
        );

        if( Auth::attempt( $logindata ) ){
            // return \Redirect::to( check group and access this controller based …
Run Code Online (Sandbox Code Playgroud)

php model-view-controller laravel laravel-5.1

5
推荐指数
1
解决办法
8177
查看次数

Flexbox的align-self属性没有转换?

我尝试创建一个吗啡“按钮”,它可以在另一个菜单上滑动。
这个想法基于 Codrops变形按钮概念

现在已经差不多设置好了,只有两件小事让我烦恼:

  • 当“关闭”菜单时,尽管我已经在过渡中设置了align-items属性,但按钮会立即下降到底部。Flexbox 不支持上述属性的转换吗?
  • 字形图标不会通过align-itemsjustify-center来调整自身,因此我不得不通过调整顶部属性来完成它。

我有点没主意了..

JSBin 示例

css flexbox css-transitions

5
推荐指数
0
解决办法
2665
查看次数

在 TypeScript 中使用带有 ES6 Promise 的 thenable 接口

一些库提供Thenable接口类型 fe AJV
我对他们有些不明白。鉴于这个最少的代码

const foo: Ajv.Thenable<boolean> = new Promise<boolean>((resolve, reject) => {
  if ("condition")
    resolve(true)

  reject("Nope")
})
Run Code Online (Sandbox Code Playgroud)

TypeScript 编译器抛出一个我无法理解的错误。

error TS2322: Type 'Promise<boolean>' is not assignable to type 'Thenable<boolean>'.
  Types of property 'then' are incompatible.
    Type '<TResult1 = boolean, TResult2 = never>(onfulfilled?: ((value: boolean) => TResult1 | PromiseLike<...' is not assignable to type '<U>(onFulfilled?: ((value: boolean) => U | Thenable<U>) | undefined, onRejected?: ((error: any) =...'.
      Types of parameters 'onfulfilled' and 'onFulfilled' are incompatible.
        Type '((value: …
Run Code Online (Sandbox Code Playgroud)

typescript es6-promise typescript-typings ajv

0
推荐指数
1
解决办法
7036
查看次数