Skip to content
Snippets Groups Projects
Commit 718a181a authored by Mads Lundegaard's avatar Mads Lundegaard
Browse files

Adding login method to login controller

parent 46f5cb3c
No related branches found
No related tags found
3 merge requests!104Weekly merge to Master,!72Remove service test,!64WIP: Implement login controller
......@@ -3,8 +3,11 @@ package NTNU.IDATT1002.controllers;
import java.io.IOException;
import NTNU.IDATT1002.App;
import NTNU.IDATT1002.service.UserService;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
/**
* Controls the buttons and changeable elements on login.fxml,
......@@ -13,8 +16,12 @@ import javafx.scene.control.Button;
*/
public class Login {
public TextField Username;
public PasswordField Password;
public Button signup;
public Button login;
private UserService userService;
/**
* Method that changes stage to Sign Up page
......@@ -31,7 +38,11 @@ public class Login {
* @throws IOException
*/
public void login(ActionEvent actionEvent) throws IOException {
//TODO: Verify username and password
App.setRoot("main");
String username = Username.getText();
String password = Password.getText();
if(userService.logIn(username, password)); {
App.setRoot("main");
}
//TODO: Else raise warning maybe?
}
}
......@@ -27,8 +27,8 @@
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Username:" GridPane.halignment="RIGHT" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Password:" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
<TextField GridPane.columnIndex="1" />
<PasswordField GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="Username" GridPane.columnIndex="1" />
<PasswordField fx:id="Password" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Button fx:id="signup" onAction="#switchToSignup" text="Sign Up" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
<Button fx:id="login" onAction="#login" layoutX="171.0" layoutY="74.0" text="Log In" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="2" />
</children>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment