Nextcloud External Login

Hello, i have a apache2 webserver on raspberry pi running, nextcloud installed and configured to use mysql. Now I have a webserver which has a login with mysql etc., but the issue is that if i want to access my files i have to login twice and if i want to create a user, i have to create it twice. Is there a way to merge both logins?
I still want to keep the old website which (for now, but i really want to merge those 2 websites too) if you press a button it redirects you to the nextcloud login. So, which file should i change if i would like to delete some functions like settings, etc. and add my own html code? My login on the external website: `
<?php
if($_SERVER[“REQUEST_METHOD”] == “POST”)
{
$myusername1=mysqli_real_escape_string($con,$_POST[‘username’]);
$mypassword1=mysqli_real_escape_string($con,$_POST[‘password’]);

        $mypassword = hash('sha256', $mypassword1);
        $mypassword=MD5($mypassword);

        $sql="SELECT * FROM login WHERE username='$myusername1' and password='$mypassword'";
        $result=mysqli_query($con,$sql);
        $row=mysqli_fetch_array($result);
        $_SESSION['id']=$row['id'];
        $_SESSION['username']=$row['username'];
        $count=mysqli_num_rows($result);
        if($count==1)
        {
                                       header ("location: ./pages/home.php");

            }
        else
        {
        $error="Your Login Name or Password is invalid";

        }
        }
        ?>
        <div class="login">
        <strong> Login </strong>
      </div>
       <div class="container">
         <br><br><div class="input-field col s6">
          <label>Username</label><input type = "text" name = "username"/>
        </div>
        <div class="input-field col s6">
          <label>Password</label><input type = "password" name = "password"/>
        </div>

            <button class="btn waves-effect waves-light" type="submit" name="action">Prisijungti
              <i class="material-icons right">send</i>
            </button>
       </div></div>
     </form>`

would like to get an answer soon, thank you.

@Pault, check this link: https://github.com/nextcloud/loginviapost
Maybe that is where you are looking for.

@aknobbe I might not doing it right, but it doesn’t work, I didn’t find a tutorial where should i put the files, so i’ve just put it in the apps folder… I understand how it works, but where should i add the new files and yea, that is mostly what I am looking for.

Pault

You need to add the downloaded folder unzipped in the app directoy.
After that you need to enable the app in Nextcloud.

When the app is active/enabled it should work.

Met vriendelijke groet,

[Boxu]https://www.boxu.nl/

Alex Knobbe | Jouw data in de cloud
Boxu B.V.
Moezel 3 2491 CV Den Haag
Tel +31 (0)88 100 2070 | Mob +31 (0)6 4063 1903
www.boxu.nl | alex@boxu.nl lmailto:alex@boxu.nl

[/uploads/default/original/2X/6/68e7563d22d28a34da38ed42945ae835c4a65723.png]https://twitter.com/BoxuCloud [/uploads/default/original/2X/b/bb8f46abe91682d2a98f1f9c3830c3d79ea727ca.png] https://www.facebook.com/BoxuCloud [/uploads/default/original/2X/2/28b7c6928cc9e8d9e4db2216cdce85fbd2cb6457.png] https://www.linkedin.com/company-beta/18200864/ [/uploads/default/original/2X/8/8827dae9cd7d6f7f96c48f9fd22fcae3e75bf582.png] https://www.youtube.com/channel/UCgWzG4ibefcDUE-txpclgWA

Gebruikt je nog Dropbox, Google Drive en WeTransfer?
Stap eenvoudig over op Boxu een maak gebruik van 1 oplossing.

DISCLAIMER:
Dit e-mailbericht is uitsluitend bestemd voor de geadresseerde en kan vertrouwelijke informatie bevatten. Verspreiding van dit e-mailbericht of van de informatie die dit e-mailbericht bevat door een ander dan de geadresseerde is verboden. Indien u dit e-mailbericht per abuis heeft ontvangen verzoeken wij u de afzender hiervan op de hoogte te brengen en het originele bericht te vernietigen. Boxu is niet verantwoordelijk en/of aansprakelijk voor eventuele gevolgen en/of schade die verzending en ontvangst alsmede de inhoud van dit e-mailbericht betreffen.

@aknobbe Thank You!! It works, but i still got some questions… How do i add a user to both servers at once (to my external login and nextcloud)? Which database it uses for adding users and what password encryption does it use? Where are it’s HTML, CSS files which are responsible for the design, because i want to put all it’s settings in a diffrent website?

@aknobbe @Pault I don’t see the link to your app. How can I download the zip? Thanks!

You need to download the whole folder @ https://github.com/nextcloud/loginviapost
There you can clone the files to zip and extract the zip to your nextcloud app folder.

Hi,

I’m using nextcloud 12 and it seems it doesn’t work anymore. Or maybe am i doing something wrong ?

  • I installed the plugin in the app directory
  • Enabled it with command line (activation weith web interface not working)
  • Used the sample form

All i get when trying is a blank submit form but nothing is filled… Any help would be appreciated !!!

Thanx !!

Can you send me the code you use at the moment as form?

I know I’m opening an old thread here, but how does the first poster’s example integrate with loginviapost?

The example form is purely to execute the standard nextcloud login and bypasses external origin etc.

so in essence: the form below when posted works perfectly and logs the user in

<form method="post" action="https://domain.co.uk/index.php/apps/loginviapost/login">
	<input type="text" name="username" />
	<input type="text" name="password"  />
	<input type="submit" value="Submit" />
</form>

whereas executing via code as below does nothing and if I subsequently go the files page I just get the log in page.

$data = array(
	'username' => 'username',
	'password' => 'password'
);

$postvars = http_build_query($data) . "\n";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://domain.co.uk/index.php/apps/loginviapost/login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);

Do you have sample code which runs an external login and also the nextcloud in one shot please? this would be great as it’s the last missing piece of my solution puzzle!

I tried it, but this is what I get:

Would also appreciate sample code to make this work,

thanks
greg

Hi, ive tried to enable loginviapost but it shows “Could not download app loginviapost”

Hi, I’m trying to use it in NC21 but it doesn’t work, in method “POST- index.php/apps/loginviapost/login” the url doesn’t respond, is it that I need to do some configuration?