Advertisement
Guest User

Untitled

a guest
Jan 13th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, helpers } from 'trinity-web'
  2. -
  3. -import { required } from 'utils/validation'
  4. -
  5. -export default class Login extends Component {
  6. -
  7. -  initialState = () => ({
  8. -    errors: null
  9. -  })
  10. -
  11. -  beforeRender() {
  12. -    this.addHeadTags(
  13. -      { tag: 'link', href: 'pub/__trinity__/vendor/font-awesome/css/font-awesome.min.css' },
  14. -      { tag: 'link', href: 'pub/__trinity__/css/main.css' },
  15. -      { tag: 'link', href: 'pub/__trinity__/css/animate.min.css' }
  16. -    )
  17. -  }
  18. -
  19. -  routeWillLeave = () => this.removeHeadTags()
  20. -
  21. -  login = ({ event }) => {
  22. -    const data = helpers.form.getFormData(event.target)
  23. -
  24. -    const errors = helpers.form.createValidator(data, {
  25. -      username: [required],
  26. -      password: [required]
  27. -    })
  28. -
  29. -    console.log(data, errors)
  30. -
  31. -    if (errors) {
  32. -      this.setState({ errors })
  33. -    }
  34. -
  35. -    event.preventDefault()
  36. -  }
  37. -
  38. -  events = () => ([
  39. -    {
  40. -      event: 'submit',
  41. -      selector: '#login-form',
  42. -      handler: this.login
  43. -    }
  44. -  ])
  45. -
  46. -  render = ({ state }) => {
  47. -    return `
  48. -      <div id="content">
  49. -        <div class="main-content">
  50. -          <div class="main-title">
  51. -            Authentication Required
  52. -          </div>
  53. -        </div>
  54. -        <div class="main-content">
  55. -          <div class="main">
  56. -            <div class="widget-large">
  57. -              <div class="title">Login</div>
  58. -              <div class="inner">
  59. -                Please login below to continue to the admin area.
  60. -              </div>
  61. -              <div class="inner"><br/>
  62. -                ${state.errors ? `
  63. -                  <div class="animated pulse infinite alert alert-danger alert-dismissible" role="alert">
  64. -                    
  65. -                    ${helpers.objectMap(state.errors,
  66. -                      (error) => `
  67. -                        <a class="close" data-dismiss="alert">
  68. -                            <span aria-hidden="true">&times;</span>
  69. -                        </a>
  70. -                        <strong>Error: </strong>${error}<br />`
  71. -                    )}
  72. -                  </div>`
  73. -                : ''}
  74. -                <form id="login-form">
  75. -                  <div class="form-group">
  76. -                    <p>Username</p>
  77. -                    <input name="username" class="form-control" id="username" type="text" aria-describedby="emailHelp" placeholder="Enter username">
  78. -                  </div>
  79. -                  <div class="form-group">
  80. -                    <p>Password</p>
  81. -                    <input name="password" class="form-control" id="password" type="password" placeholder="Password">
  82. -                  </div>
  83. -                  <p>
  84. -                    <button name="login-submit" type="submit" class="btn btn-blue" value="Login">Login</button>
  85. -                  </p>
  86. -                </form>
  87. -              </div>
  88. -            </div>
  89. -            <div class="widget-beware">
  90. -              <div class="title">
  91. -                <i class="fa fa-exclamation-triangle"> </i>
  92. -                Beware
  93. -              </div>
  94. -              <div class="inner">
  95. -                Failed login attempts are recorded and may expose your ip address and/or browser information, continue at your own risk.
  96. -              </div>
  97. -            </div>
  98. -          </div>
  99. -        </div>
  100. -      </div>
  101. -    `
  102. -  }
  103. -
  104. -}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement