我正在研究凤凰应用程序。认证部分是通过Guardian
实现的。
类似于典型的网站,该应用程序具有页眉,页脚和侧边栏。这些是布局文件夹中的静态页面。
树状视图
-lib
|--admin_app_web
|--templates
|--layouts
|--app.html.eex
|--header.html.eex
|--sidebar.html.eex
|--main.html.eex
app.html.eex
看起来像这样
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
</head>
<body>
<%= render "header.html", conn: @conn%>
<%= render "flash.html", conn: @conn%>
<%= render "main.html", assigns %>
<%=# render "footer.html" %>
<script src="<%= static_path(@conn, "/js/app.js") %>"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
</body>
</html>
main.html.eex
在这些行上
<main role="main" class="row my-3">
<div class="col-2">
<%= render "sidebar.html" %>
</div>
<div class="col">
<%= render @view_module, @view_template, assigns %>
</div>
</main>
我只想渲染sidebar.html.eex
为user
的{{1}},如何实现呢??
答案 0 :(得分:1)
您可以检查用户是否使用org.springframework.aop.framework.ProxyFactory: 2 interfaces [br.com.pixinside.projection.ResearchSimple, org.springframework.data.projection.TargetAware]; 3 advisors [org.springframework.aop.support.DefaultPointcutAdvisor: pointcut [Pointcut.TRUE]; advice [org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor@1d62a0b], org.springframework.aop.support.DefaultPointcutAdvisor: pointcut [Pointcut.TRUE]; advice [org.springframework.data.projection.ProxyProjectionFactory$TargetAwareMethodInterceptor@3b89f41a], org.springframework.aop.support.DefaultPointcutAdvisor: pointcut [Pointcut.TRUE]; advice [org.springframework.data.projection.ProjectingMethodInterceptor@198453c9]]; targetSource [SingletonTargetSource for target object [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap@319267ad]]; proxyTargetClass=false; optimize=false; opaque=true; exposeProxy=false; frozen=false
进行了身份验证,并使用Guardian.Plug.authenticated?/2
选择性地渲染侧边栏模板。
if