Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Custom login on scout(Custom login on scout)
Custom login on scout [message #1752488] Tue, 24 January 2017 12:27 Go to next message
juliano ferreira borges is currently offline juliano ferreira borgesFriend
Messages: 4
Registered: December 2016
Location: Brasil
Junior Member
Good morning. I am creating an application that has as basic requirement that in the screen of login it is possible to recover the password of the user. The idea would be to create a button on the login screen I forgot my password and in recovery a temporary password will be sent by email to the user. How can I do this in scout? Create a button or a link on the login screen.
Re: Custom login on scout [message #1752568 is a reply to message #1752488] Wed, 25 January 2017 08:31 Go to previous messageGo to next message
Paolo Bazzi is currently offline Paolo BazziFriend
Messages: 15
Registered: January 2017
Junior Member
Hi Juliano

Quote:
How can I do this in scout? Create a button or a link on the login screen.


You need to override and replace the Scout LoginBox with an own extended implementation. This is possible, using the current Scout version, but not very straightforward. We improved the extensibility of the LoginBox with the next Scout Oxygen release.

Steps:
Create a new LoginBox implementation extending the Scout LoginBox:

\helloworld.ui.html\src\main\js\helloworld\LoginBox.js
helloworld.LoginBox = function(opts) {
  helloworld.LoginBox.parent.call(this, opts);
};

scout.inherits(helloworld.LoginBox, scout.LoginBox);

helloworld.LoginBox.prototype.init = function(opts) {
	helloworld.LoginBox.parent.prototype.init.call(this, opts);
};

helloworld.LoginBox.prototype.render = function($parent) {
  helloworld.LoginBox.parent.prototype.render.call(this, $parent);

  this.$resetButton = $('<button>')
  .addClass('button')
  .text('Reset password')
  .click(this._onResetPasswordButton.bind(this))
  .appendTo(this.$content);
};

helloworld.LoginBox.prototype._onResetPasswordButton = function(event) {
	alert('do something');
};


Use the _onResetPasswordButton method to perform a call to the server to send out the new password. Check out scout.LoginBox_onLoginFormSubmit() method for an example.

Then add your own login.js to create the new LoginBox instance:

helloworld.ui.html\src\main\js\helloworld\login.js
scout.login = {
  init: function(opts) {
    scout.prepareDOM();
    var loginBox = new helloworld.LoginBox(opts);
    loginBox.render($('body'));
  }
};


Then to have your own JavaScript code loaded, create a new login-macro file:

helloworld.ui.html\src\main\resources\WebContent\res\application-all-login-macro.js
__include("scout-login-module.js");
__include("hello-world-login-module.js")


And finally, add your macro file to your login.html file:

\helloworld.ui.html\src\main\resources\WebContent\login.html
...
    <scout:script src="res/jquery-all-macro.js" />
    <scout:script src="res/application-all-login-macro.js" />
...


Cheers,
Paolo

[Updated on: Wed, 25 January 2017 11:41]

Report message to a moderator

Re: Custom login on scout [message #1752640 is a reply to message #1752568] Wed, 25 January 2017 17:23 Go to previous messageGo to next message
juliano ferreira borges is currently offline juliano ferreira borgesFriend
Messages: 4
Registered: December 2016
Location: Brasil
Junior Member
Good afternoon .
Thanks for the answer.
It worked out.

[Updated on: Wed, 25 January 2017 19:53]

Report message to a moderator

Re: Custom login on scout [message #1752685 is a reply to message #1752640] Thu, 26 January 2017 08:09 Go to previous message
Paolo Bazzi is currently offline Paolo BazziFriend
Messages: 15
Registered: January 2017
Junior Member
juliano ferreira borges wrote on Wed, 25 January 2017 17:23
Good afternoon .
Thanks for the answer.
It worked out.

Good to hear! Therefore you're working with Eclipse Neon release Wink

Regards,
Paolo
Previous Topic:[neon] How to replace org.osgi.service.prefs.Preferences
Next Topic:How to connect two Scout Projects?
Goto Forum:
  


Current Time: Thu Oct 19 09:22:49 GMT 2017

Powered by FUDForum. Page generated in 0.02868 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software