2016-05-05 151 views
2

我希望給登錄頁面驗證用戶,然後將其重定向到jHipster已創建主頁。 登錄頁面是用戶應該看到更改jHipster登錄驗證頁面

{ 
    "generator-jhipster": { 
    "jhipsterVersion": "3.0.0", 
    "baseName": "vconnect", 
    "packageName": "com.zenfact.vconnect", 
    "packageFolder": "com/zenfact/vconnect", 
    "serverPort": "8080", 
    "authenticationType": "session", 
    "hibernateCache": "ehcache", 
    "clusteredHttpSession": "no", 
    "websocket": "no", 
    "databaseType": "sql", 
    "devDatabaseType": "postgresql", 
    "prodDatabaseType": "postgresql", 
    "searchEngine": "elasticsearch", 
    "buildTool": "maven", 
    "enableSocialSignIn": false, 
    "rememberMeKey": "559bbe3167552d040ba24d16506d389a7ba851c3", 
    "useSass": false, 
    "applicationType": "monolith", 
    "testFrameworks": [ 
     "gatling" 
    ], 
    "enableTranslation": true, 
    "nativeLanguage": "en", 
    "languages": [ 
     "en", 
     "zh-cn", 
     "fr", 
     "hi", 
     "ja" 
    ] 
    } 
} 

的第一件事,這是我在做的index.html

<div ui-view="navbar" ng-cloak></div> 
<div class="container"> 
    <div class="well" ui-view="content"> 
    </div> 
    <div class="modal-body" ng-controller="LoginController as vm" ng-hide="vm.isAuthenticated()" data-ng-init="translate()"> 
    <div class="row"> 
     <div class="col-md-4 col-md-offset-4"> 
      <h1 translate="login.title">Sign in</h1> 
     </div> 
     <div class="col-md-8 col-md-offset-2"> 
      <div class="alert alert-danger" ng-show="vm.authenticationError" translate="login.messages.error.authentication"> 
       <strong>Failed to sign in!</strong> Please check your credentials and try again. 
      </div> 
     </div> 
     <div class="col-md-8 col-md-offset-2"> 
      <form class="form" role="form" ng-submit="vm.login($event)"> 
       <div class="form-group"> 
        <label for="username" translate="global.form.username">username</label> 
        <input type="text" class="form-control" id="username" placeholder="userName" ng-model="vm.username"> 
       </div> 
       <div class="form-group"> 
        <label for="password" translate="login.form.password">Password</label> 
        <input type="password" class="form-control" id="password" placeholder="password" 
          ng-model="vm.password"> 
       </div> 
       <div class="form-group"> 
        <label for="rememberMe"> 
         <input type="checkbox" id="rememberMe" ng-model="vm.rememberMe" checked> 
         <span translate="login.form.rememberme">Remember me</span> 
        </label> 
       </div> 
       <button type="submit" class="btn btn-primary" translate="login.form.button">Sign in</button> 
      </form> 
      <p></p> 
      <div class="alert alert-warning"> 
       <a class="alert-link" href="" ng-click="vm.requestResetPassword()" translate="login.password.forgot">Did you forget your password?</a> 
      </div> 
      <div class="alert alert-warning" translate="global.messages.info.register" translate-compile> 
       You don't have an account yet? <a class="alert-link" href="" ng-click="vm.register()">Register a new account</a> 
      </div> 
     </div> 
    </div> 
</div> 

我希望有登錄頁面默認頁面,驗證用戶然後根據結果重定向用戶。在home.state.js

回答

3

編輯家鄉需要認證

  authorities: ['ROLE_USER'], 
+1

截至目前jhipster提供index.html作爲默認頁,我希望有一個登錄頁面,默認頁,其驗證的任何用戶和然後將用戶重定向到索引頁面。當我在index.html中插入登錄代碼時,它沒有翻譯 – abhi314

+1

我已經在index.html上面添加了上述問題所做的更改 – abhi314

+1

在修改index.html之前,您是否嘗試過我提出的建議?它應該做什麼你想要的最小的變化。如果您在未經身份驗證的情況下前往主頁,則會重定向到登錄頁面。如果您不瞭解權限(權限)的工作方式,則可能會增加複雜性或創建安全問題 –