Code Monkey home page Code Monkey logo

vaadin-component-login's Introduction

RapidPM Vaadin Component - Login

A simple Login Screen - boring but usefull ;-) This is for Vaadin 10, build on a JDK10 but with

    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>

Why?

A Login Screen is often used, and a repetive task to create if you are creating smaller apps, demos, and so on.

For this I created the component, da work with dependencies instead of copy-paste. even in my examples.

How it looks like ?

_data/RapidPM_Vaadin_Component-Login.gif

How?

You can use this as a dependency. The only thing you have to do is to create the the connection to your app.

Step 1 - connect to your Auth - Service

The first method to create is the method with the name public abstract boolean checkCredentials();

Here you have to decide if the provided credentials are valid or not. In the demo/test Source folder you will find the class MyLoginView The implementation in this class is for demo usage only.

  @Override
  public boolean checkCredentials() {
    String username = username();
    String password = password();

    // USE Apache Shiro for example : demo you can find here
    // https://github.com/Nano-Vaadin-Demos/nano-vaadin-meecrowave-shiro-V10

    // DON NOT USE THIS IN PRODUCTION !!
    boolean isOK = username != null && username.equals("admin") ||
                   password != null && password.equals("admin");

    UI.getCurrent().getSession().setAttribute(LOGGED_IN, isOK);
    // DON NOT USE THIS IN PRODUCTION !!

    return isOK;
  }

Step 2 - what to do if auth failed

Define what should happen if the Auth-Service will reject the provided credentials. In this example there will be a Notification shown and a logger message created.

  @Override
  public void reactOnFailedLogin() {
    logger().warning("Login is not acctepd..");
    Notification.show("Credentials not accepted..");
  }

Step 3 - what to do if auth is OK

Now we can redirect to the next View. In this example a demo view with no special meaning.

  @Override
  public void navigateToApp() {
    UI.getCurrent().navigate(MainView.class);
  }

Demo Usage

In the test folders you will find a fully working demo app to show a dummy implementation. If you want to see samo more examples, for example how to use this with Shiro, have a look at https://github.com/Nano-Vaadin-Demos/nano-vaadin-meecrowave-shiro-V10

ROADMAP

  • I18n will be added
  • TDD / PageObjects based on Testbench NG and jUnit5

How to connect?

Feel free to ping me ..

  • email sven.ruppert (a) gmail.com
  • Twitter - @SvenRuppert

vaadin-component-login's People

Contributors

svenruppert avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.