Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/NFDI4Chem/nmrxiv into prod-…
Browse files Browse the repository at this point in the history
…helm-deploy
  • Loading branch information
NishaSharma14 committed Dec 8, 2023
2 parents b96eada + b969f99 commit 6c55d06
Show file tree
Hide file tree
Showing 83 changed files with 9,645 additions and 8,204 deletions.
6 changes: 0 additions & 6 deletions .env.ci.test
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,3 @@ TWITTER_CLIENT_SECRET=
TWITTER_REDIRECT_URL=http://localhost:80/auth/login/twitter/callback

TELESCOPE_ENABLED=false

#Bioschema Properties.
NMRXIV_PROVIDER=NFDI4Chem
NMRXIV_PROVIDER_URL=https://www.nfdi4chem.de/
MEASUREMENT_TECHNIQUE=http://purl.obolibrary.org/obo/CHMO_0000613

10 changes: 2 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=info@nmrxiv.org
MAIL_FROM_ADDRESS=info.nmrxiv@uni-jena.de
MAIL_FROM_NAME="${APP_NAME}"

FILESYSTEM_DRIVER=minio
Expand Down Expand Up @@ -92,15 +92,9 @@ ORCID_ENVIRONMENT=sandbox

TELESCOPE_ENABLED=false

#Bioschema Properties.
NMRXIV_PROVIDER=NFDI4Chem
NMRXIV_PROVIDER_URL=https://www.nfdi4chem.de/
MEASUREMENT_TECHNIQUE=http://purl.obolibrary.org/obo/CHMO_0000613

#DATACITE Properties
DOI_HOST=datacite
DATACITE_USERNAME=
DATACITE_SECRET=
DATACITE_PREFIX=
DATACITE_ENDPOINT=

DATACITE_ENDPOINT=
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Changelog

## [1.1.0-rc.15](https://github.com/NFDI4Chem/nmrxiv/compare/v1.0.0-rc.15...v1.1.0-rc.15) (2023-12-08)


### Features

* add public api for Dataset and Samples ([265d3bc](https://github.com/NFDI4Chem/nmrxiv/commit/265d3bcb8ede27039e3c8ea07db385b9aa47e7f9))


### Bug Fixes

* add L5 Swagger package and fix imort error ([385a0ec](https://github.com/NFDI4Chem/nmrxiv/commit/385a0ecc9180fb1142cfd98e832d4567904d003d))
* add swagger doc for auths and public projects ([f7ce84f](https://github.com/NFDI4Chem/nmrxiv/commit/f7ce84f9b2818478799755146024a6f0b57d6416))
* add swagger for bioschemas ([dcd05f8](https://github.com/NFDI4Chem/nmrxiv/commit/dcd05f8952dd2988dc12706e5dd83ecfab177362))
* add unique constraint to shouldbeunique ([8850dfb](https://github.com/NFDI4Chem/nmrxiv/commit/8850dfbee9714a2b863d86a40606775e5c5b01a0))
* added confirmation modal to the publish screen ([9861022](https://github.com/NFDI4Chem/nmrxiv/commit/98610223b19d952b71231a4493bf6d412eb9903a))
* api endpoints updates ([c8d34f0](https://github.com/NFDI4Chem/nmrxiv/commit/c8d34f00e9791be46f1dd09ddacc38a8c70ad3fc))
* app env check updates ([b3a3a9a](https://github.com/NFDI4Chem/nmrxiv/commit/b3a3a9a859d0e433f5055819f22a7695fcb8d988))
* disabled action when project is deleted. ([54838aa](https://github.com/NFDI4Chem/nmrxiv/commit/54838aaff32ac360b91318502fc2d58db748b792))
* enabled compounds preview and other minor updates ([0dca4ee](https://github.com/NFDI4Chem/nmrxiv/commit/0dca4ee6c5dcf05ff4235111f26cf69b567ff275))
* enabled compounds summary info view by default ([3184be0](https://github.com/NFDI4Chem/nmrxiv/commit/3184be0b7b4bf99104ee5e22bc5b5fd905295533))
* Exception missing import fix ([f81b025](https://github.com/NFDI4Chem/nmrxiv/commit/f81b02552ad771411845068a233ae040b5f5cf3c))
* failing tests resolved ([b853010](https://github.com/NFDI4Chem/nmrxiv/commit/b8530102ee6314cda016679aeeb862e78a89bf3c))
* formatting and composer conflict resolution ([64ccbfc](https://github.com/NFDI4Chem/nmrxiv/commit/64ccbfc689f2e5c19ecf9f28f5bca13aa109780d))
* formatting, UX/UI updates and zipping bug fix ([1718138](https://github.com/NFDI4Chem/nmrxiv/commit/17181389d2f930ba1e5d109ff22a862445d1135c))
* hide empty tags placeholder ([cb33a78](https://github.com/NFDI4Chem/nmrxiv/commit/cb33a78620b584a1fc334824ef7aab29da2e345d))
* independent sample rendering issue fix ([9e7d565](https://github.com/NFDI4Chem/nmrxiv/commit/9e7d565fcc805caeb37bd8870ef9d2be332fdacf))
* many datacite fixes ([58a3960](https://github.com/NFDI4Chem/nmrxiv/commit/58a3960c9c569b0c371b2c30e6da896a1138b35b)), closes [#560](https://github.com/NFDI4Chem/nmrxiv/issues/560)
* move query to path in models swagger ([c519798](https://github.com/NFDI4Chem/nmrxiv/commit/c5197988958e9bc739445cdf0ddf36422a1e96e3))
* moved env to config and various other minor refactoring ([2b2460a](https://github.com/NFDI4Chem/nmrxiv/commit/2b2460acee49dbb228ab392785567c21c6d3a7b2))
* project archival mail issue ([3bf9608](https://github.com/NFDI4Chem/nmrxiv/commit/3bf9608d0e4d9fd6f5694d9e5959906282636c96))
* refactored upload view, updated controllers and various bug fixes ([4fb0d5f](https://github.com/NFDI4Chem/nmrxiv/commit/4fb0d5fb0dbd6726bdc9054368f12553423c68df))
* register api 422 error in swagger ([5c08136](https://github.com/NFDI4Chem/nmrxiv/commit/5c08136a5b1fb7cbfa41385b5ceb6ed58f25aa96))
* remove abstract Bioschemas models ([63daccf](https://github.com/NFDI4Chem/nmrxiv/commit/63daccf2549eb09b3e3a2a7aeb26549855291bfa))
* resolve 404 error in Search ([526e92a](https://github.com/NFDI4Chem/nmrxiv/commit/526e92a2b6e9342facbbee637e3619992faaefb1)), closes [#846](https://github.com/NFDI4Chem/nmrxiv/issues/846)
* restore project - draft bug fix and dashboard broken links fix ([b0057db](https://github.com/NFDI4Chem/nmrxiv/commit/b0057dbad28057ebd58f7a8a8b346997e4b04fc8))
* samples mode publishing bug fix ([d8caad8](https://github.com/NFDI4Chem/nmrxiv/commit/d8caad8a32231c10d85e8a89f484f2d2077c63ed))
* updating delete projects names to enable name reusing ([ed3e18c](https://github.com/NFDI4Chem/nmrxiv/commit/ed3e18c5697c2365106dfb6cbb706bb72cf77510))
* ux/ui improvements and other bug fixes ([3406aa9](https://github.com/NFDI4Chem/nmrxiv/commit/3406aa94b03b6eade5b2086aa0ff3c76174f1c92))
* various minor fixes ([f61f25c](https://github.com/NFDI4Chem/nmrxiv/commit/f61f25cbc7eabed6ec1ba4ba212366bf5f18e333))

## [1.1.0-rc.14](https://github.com/NFDI4Chem/nmrxiv/compare/v1.0.0-rc.14...v1.1.0-rc.14) (2023-11-28)


Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Project/ArchiveProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public function toggle($project)
$study->datasets()->update(['is_archived' => $archiveState]);
}
$project->is_archived = $archiveState;
$project->save();
if ($project->is_archived) {
$project->sendNotification('archival', $this->prepareSendList($project));
}
$project->save();
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/Actions/Project/DeleteProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function delete($project)
if ($draft) {
$draft->update(['is_deleted' => true]);
}
$project->name = $project->name.'- deleted';
$project->deleted_on = Carbon::now();
$project->is_deleted = true;
$project->sendNotification('deletion', $this->prepareSendList($project));
Expand Down
3 changes: 3 additions & 0 deletions app/Actions/Project/RestoreProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public function restore($project)
foreach ($project->studies as $study) {
$study->datasets()->update(['is_deleted' => false]);
}
$draft = $project->draft;
$draft->is_deleted = false;
$draft->save();
$project->is_deleted = false;
$project->save();
}
Expand Down
1 change: 0 additions & 1 deletion app/Actions/Project/UpdateProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function update(Project $project, array $input)
Validator::make($input, [
'name' => ['required', 'string', 'max:255', Rule::unique('projects')
->where('owner_id', $project->owner_id)->ignore($project->id), ],
'description' => ['required', 'string', 'min:20'],
'license' => ['required_if:is_public,"true"'],
], $errorMessages)->validate();

Expand Down
1 change: 1 addition & 0 deletions app/Events/ProjectInvite.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Events;

use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;

class ProjectInvite implements ShouldBroadcastNow
Expand Down
1 change: 1 addition & 0 deletions app/Events/StudyInvite.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Events;

use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;

class StudyInvite implements ShouldBroadcastNow
Expand Down
50 changes: 50 additions & 0 deletions app/Http/Controllers/API/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,39 @@

class LoginController extends Controller
{
/**
* @OA\Post(
* path="/api/auth/login",
* summary="Sign in",
* description="Login by email and password",
* operationId="authLogin",
* tags={"auth"},
*
* @OA\RequestBody(
* required=true,
* description="Pass user credentials",
*
* @OA\JsonContent(
* required={"email","password"},
*
* @OA\Property(property="email", type="string", format="email", example="[email protected]"),
* @OA\Property(property="password", type="string", format="password", example="secret1234"),
* ),
* ),
*
* @OA\Response(
* response=200,
* description="Successful Operation",
* ),
* @OA\Response(
* response=401,
* description="Wrong Credentials Response",
* ),
* )
*/
public function login(Request $request): JsonResponse
{

if (! Auth::attempt($request->only('email', 'password'))) {
return response()->json([
'message' => 'Invalid login details',
Expand All @@ -20,6 +51,12 @@ public function login(Request $request): JsonResponse

$user = User::where('email', $request['email'])->firstOrFail();

if (! $user->hasVerifiedEmail()) {
return response()->json([
'message' => 'Account is not yet verified. Please verify your email address by clicking on the link we just emailed to you.',
], 403);
}

$token = $user->createToken('auth_token')->plainTextToken;

return response()->json([
Expand All @@ -28,6 +65,19 @@ public function login(Request $request): JsonResponse
]);
}

/**
* @OA\Get(
* path="/api/auth/logout",
* summary="Sign out",
* tags={"auth"},
* security={{"sanctum":{}}},
*
* @OA\Response(
* response=200,
* description="successful operation"
* ),
* )
*/
public function logout(Request $request): JsonResponse
{
$request->user()->currentAccessToken()->delete();
Expand Down
117 changes: 99 additions & 18 deletions app/Http/Controllers/API/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,117 @@
namespace App\Http\Controllers\API\Auth;

use App\Http\Controllers\Controller;
use App\Models\Team;
use App\Models\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

class RegisterController extends Controller
{
public function register(Request $request): JsonResponse
/**
* Register
*
* @OA\Post (
* path="/api/auth/register",
* tags={"auth"},
*
* @OA\RequestBody(
*
* @OA\MediaType(
* mediaType="application/json",
*
* @OA\Schema(
* required={"first_name","last_name","email","password","username"},
*
* @OA\Property(property="first_name", type="string", format="first_name", example="Nisha"),
* @OA\Property(property="last_name", type="string", format="last_name", example="Sharma"),
* @OA\Property(property="email", type="string", format="email", example="[email protected]"),
* @OA\Property(property="username", type="string", format="username", example="nis123"),
* @OA\Property(property="orcid_id", type="string", format="orcid_id", example="0009-0006-4755-1039"),
* @OA\Property(property="password", type="string", format="password", example="secret1234"),
* )
* )
* ),
*
* @OA\Response(
* response=201,
* description="Success",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="User creation successful. Kindly confirm your email address by clicking the link sent to your inbox"),
* @OA\Property(property="access_token", type="string", example="randomtokenasfhajskfhajf398rureuuhfdshk"),
* @OA\Property(property="token_type", type="string", example="bearer"),
* )
* ),
*
* @OA\Response(
* response=422,
* description="Unprocessable Content"
* )
* )
*/
public function register(Request $request)
{
$validatedData = $request->validate([
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:8',
'orcid_id' => string,
'affiliation' => string,
]);

$user = User::create([
'name' => $validatedData['name'],
'email' => $validatedData['email'],
'orcid_id' => $validatedData['orcid_id'],
'affiliation' => $validatedData['affiliation'],
'password' => Hash::make($validatedData['password']),
]);
$validateUser = Validator::make($request->all(),
[
'first_name' => 'required|string|max:255',
'last_name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:8',
'username' => 'required|string',
]);

if ($validateUser->fails()) {
return response()->json([
'status' => false,
'message' => 'validation error',
'errors' => $validateUser->errors(),
], 401);
}

$user = DB::transaction(function () use ($request) {
return tap(User::create([
'name' => $request['first_name'].' '.$request['last_name'],
'first_name' => $request['first_name'],
'last_name' => $request['last_name'],
'email' => $request['email'],
'username' => $request['username'],
'orcid_id' => $request['orcid_id'],
'affiliation' => $request['affiliation'],
'password' => Hash::make($request['password']),
]), function (User $user) {
$this->createTeam($user);
$user->sendEmailVerificationNotification();
});
});

$token = $user->createToken('auth_token')->plainTextToken;

return response()->json([
'success' => true,
'message' => 'User creation successful. Kindly confirm your email address by clicking the link sent to your inbox.',
'access_token' => $token,
'token_type' => 'Bearer',
]);
],
201);
}

/**
* Create a personal team for the user.
*
* @return void
*/
protected function createTeam(User $user)
{
$user->ownedTeams()->save(Team::forceCreate([
'user_id' => $user->id,
'name' => explode(' ', $user->first_name.' '.$user->last_name, 2)[0]."'s Team",
'personal_team' => true,
]));
}
}
13 changes: 13 additions & 0 deletions app/Http/Controllers/API/Auth/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@

class UserController extends Controller
{
/**
* @OA\Get(
* path="/api/auth/user/info",
* summary="User info",
* tags={"auth"},
* security={{"sanctum":{}}},
*
* @OA\Response(
* response=200,
* description="successful operation"
* ),
* )
*/
public function info(Request $request)
{
return $request->user();
Expand Down
Loading

0 comments on commit 6c55d06

Please sign in to comment.